Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix issue #4037 where uploading a file could remove EXIF data #4162

Open
wants to merge 4 commits into
base: 7.dev
Choose a base branch
from

Conversation

bryannielsen
Copy link
Contributor

When an image is uploaded to an Upload Destination using a local filesystem adapter we will move the file in a way that preserves any EXIF data present. Note that if any transformations are performed upon upload the EXIF data may be removed if the image processing library does not support EXIF.

When an image is uploaded to an Upload Destination using a local filesystem adapter we will move the file in a way that preserves any EXIF data present.  Note that if any transformations are performed upon upload the EXIF data may be removed if the image processing library does not support EXIF.
@bryannielsen bryannielsen added the Bug: Accepted Bug has been confirmed, is reproducible, and ready to work on. label Mar 21, 2024
@bryannielsen bryannielsen added this to the 7.4.6 milestone Mar 21, 2024
intoeetive
intoeetive previously approved these changes Mar 22, 2024
Copy link
Contributor

@intoeetive intoeetive left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did not test through different environments, but the code looks good to me

@intoeetive intoeetive dismissed their stale review March 22, 2024 06:42

Does not seem to work though :) The upload tests are failing

@bryannielsen
Copy link
Contributor Author

@intoeetive tests are passing now, I'm also hoping that @jcogs-design can chime in when he has a chance and see if this resolves the original issue.

@bryannielsen bryannielsen modified the milestones: 7.4.6, 7.x, 7.4.7 Mar 27, 2024
@bryannielsen bryannielsen modified the milestones: 7.4.7, 7.4.8, 7.4.9 Apr 15, 2024
@bryannielsen bryannielsen modified the milestones: 7.4.9, 7.4.10 Apr 22, 2024
@jcogs-design
Copy link
Contributor

jcogs-design commented Apr 25, 2024

Apologies for delay in responding to this.
All seems to work OK here.
One observation though. The edits to Upload.php include this comment

     * Move the file to the final destination
     *
     * If we have an UploadDestination and it is not a local filesystem
     * we will write the stream of data to that remote filesystem
     *
     * Otherwise we will act locally to avoid potentially losing EXIF data
     * To deal with different server configurations we'll attempt to use
     * copy() first.  If that fails we'll use move_uploaded_file().
     * One of the two should reliably work in most environments
     */

From what testing I've done it looks like the Flysystem file utilities preserve EXIF data (so if you upload an EXIF bearing file to an EE7 Cloud File S3 folder and then download it again, the downloaded file still has EXIF data attached). So possibly if this is true also for the Flysystem Local Adapter (and presumably it will be) then you maybe can avoid having the split local vs. remote code, and simply use Flysystem throughout.

HTH
🐾

@bryannielsen
Copy link
Contributor Author

@jcogs-design thanks for taking a look!

That's interesting about what you're observing with remote filesystems and EXIF data. The current code is using Flysystem for the local filesystem as well as remote ones but that seems to be what causes the loss of EXIF data locally. Did your environment that you were testing on have EXIF support compiled into PHP?

@jcogs-design
Copy link
Contributor

I'm not sure why basic file operations in php would remove EXIF regardless of whether php is built with the EXIF library installed.

@bryannielsen bryannielsen modified the milestones: 7.4.10, 7.x May 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug: Accepted Bug has been confirmed, is reproducible, and ready to work on.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants