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

Use JS to read image dimensions on upload #2705

Open
wants to merge 3 commits into
base: 3.x
Choose a base branch
from

Conversation

13twelve
Copy link
Member

@13twelve 13twelve commented Dec 5, 2024

Description

The issue

Some jpegs are taken in one orientation and then rotated on a device and exported such that the display of the image doesn't seem to match the dimensions. The result is you upload what you think is a portrait image but is actually a landscape image, which EXIF data set to rotate the image. This then gives un-expected results in the image cropping tool and on the front end.

The fix

Halt the fine-uploader by using a promise on the submit callback of fine-uploader, until after the image has loaded and JavaScript has had a change to grab the image dimensions. Previously the upload was completing before the image had been loaded and so image dimensions were not being sent.

And then we're using the supplied values from the front end when storing the values.

The issue: some jpegs are taken in one orientation and then rotated
on a device and exported such that the display of the image doesn't
seem to match the dimensions. The result is you upload what you
think is a portrait image but is actually a landscape image, which
EXIF data set to rotate the image. This then gives un-expected results
in the image cropping tool and on the front end.

The fix: halt the fine-uploader by using a promise on the submit
callback of fine-uploader, until after the image has loaded and
JavaScript has had a change to grab the image dimensions.

(previously the upload was completing before the image had been loaded
and so image dimensions were not being sent)
@@ -187,6 +187,11 @@ public function storeFile($request)

[$w, $h] = getimagesize($uploadedFile->path());
Copy link
Member

@ifox ifox Dec 5, 2024

Choose a reason for hiding this comment

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

@13twelve let's move this into an else below to avoid the extra call if we don't need it?

Copy link
Member Author

Choose a reason for hiding this comment

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

Updated

@13twelve 13twelve requested a review from ifox December 5, 2024 14:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants