DragonByte Tech
Well-known member
- Affected version
- 2.3.6
Currently, it is impossible to fully preserve an attachment's EXIF data. There's a number of factors at play here:
I have attached a sample image which, when adding debug statements, causes these prints:

This is the relevant portion of
As seen in this suggestion: https://xenforo.com/community/threads/retain-exif-data-on-optimized-processed-images.225525/ there are numerous instances where preserving all EXIF data is beneficial. Therefore, I suggest the following fix:
- The bundled
ExifReader
library fails to obtain all EXIF data from sample photos found here: https://www.geoimgr.com/sample-photos.html and other sample photos I have tested with XF.ImageTools.resize()
does not abort resizing if the global image size limits are set to 0 or left blankXF.ImageTools.resize()
will always discard the old image because the canvas size will always be smaller than the original image
I have attached a sample image which, when adding debug statements, causes these prints:

This is the relevant portion of
XF.ImageTools.resize()
:
JavaScript:
const newFile = new File([blob], file.name, {
type: asType,
lastModified: file.lastModified,
})
console.log("New file size:", newFile.size)
console.log("Old file size:", file.size)
if (!neededResizing && newFile.size >= file.size)
{
console.log("Preserved old file")
resolve(file)
return
}
console.log("Replaced with new file")
resolve(newFile)
As seen in this suggestion: https://xenforo.com/community/threads/retain-exif-data-on-optimized-processed-images.225525/ there are numerous instances where preserving all EXIF data is beneficial. Therefore, I suggest the following fix:
Diff:
Index: js/xf/attachment_manager.js
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/js/xf/attachment_manager.js b/js/xf/attachment_manager.js
--- a/js/xf/attachment_manager.js
+++ b/js/xf/attachment_manager.js
@@ -1073,6 +1073,12 @@
neededResizing = false
}
+ if (!neededResizing)
+ {
+ resolve(file)
+ return
+ }
+
if (maxWidth && width > maxWidth)
{
height *= maxWidth / width