Image rotation after upload #3530
Comments
Hi @includebrasil , rotation of images has two aspects:
If you make a picture with your camera, one in landscape and one in portrait mode, the camera stores both of them in the same pixel format, let's assume in an aspect ratio of 4:3. When using jQuery File Upload, it gets more complex, due to the following aspects:
If you enable client-side image re-orientation for the original images, but keep the meta-data intact, you might have a mismatch between image data and EXIF orientation. So my advice is to look into all of these aspects and then apply the appropriate configs according to your setup and requirements. Please also kindly note that this issue tracker is not meant for support-requests:
|
Closing this as support request. |
Sorry for re-opening this issue, but there is a fundamental flaw in the auto-rotate feature, especially now in 2020 that many browsers support EXIF rotation, also for inline images. My main question is: When you rotate an image with jQuery-File-Upload, is there no way to simultaneously correct the rotation value that is stored in the EXIF meta data? As it works now:
Furthermore, let's say we want to rotate images and/or create thumbnails in PHP, based on the EXIF orientation value. PHP will now attempt to rotate the image based on EXIF rotation, but it has no idea that the image is already rotated. The result will be a duplicate rotation, causing more havoc. There is no way for PHP to know now what the correct orientation of the image is. Server orientation disableImageMetaDataSave imageOrientation false So the question remains, is it not possible to correct the EXIF orientation value after rotate? If so, surely there is no reason to not do this. |
Hi Karl, my answer above is somewhat out-of-date, since jQuery File Upload does update the EXIF orientation value after auto-rotation since version The specific code is here: jQuery-File-Upload/js/jquery.fileupload-image.js Lines 323 to 326 in 6d1dd9b
Since image orientation is part of blueimp-load-image, the documentation for this feature is here: |
Oh wow, indeed. I was testing from 10.8.0. Thanks, and great job with everything! |
Thanks! |
I think I came across a bug, possibly new: When When For the record, I discovered this because our app has an option to 1. rotate on upload (jQuery-File-Upload), or 2. Rotate by PHP after upload. In the case option 2 is selected, In the case |
I agree with mjau-mjau. I am having the same problem. For some reason when imageOrientation is set to false and disableImageResize is false, the uploaded image is getting rotated. Any idea how to fix this? |
@mjau-mjau and @Sherbert99:
Unfortunately as of now, it is not possible to disable the browser image orientation for images loaded outside of the DOM, see my related comment here: w3c/csswg-drafts#4666 (comment) What you can do is instruct the library to re-orient auto-oriented images back to their original orientation with the setting See also the orientation documentation for the underlying |
@blueimp I must object. I am not talking about https://caniuse.com/#feat=css-image-orientation, which most browsers now do automatically. Besides, you can prevent the browser from automatically orienting image to EXIF by using CSS I'm saying that jQuery-File-Upload actually rotates the image physically, even when
That is not the case though. The library is applying orientation even when Would be happy to create a test case. For the record, I have been developing www.photo.gallery for 15 years, and I know all the problematics involved with image orientation. I was very glad to see that JFU now corrects the EXIF tag after it rotates the image. However, it is still rotating the image now with |
Or maybe there is something I am not aware of after reading your post on w3c. Seems very strange if this is the case. Basically it means it's not feasible to use |
This is only true for images loaded inside of the DOM, as CSS is simply not applied to My comment there also includes a link to a test page that showcases the browser behaviors for
If you're scaling images, the library has to draw them to a canvas and then create Blob objects from the resulting image pixel data. |
Hmmm, I think I get it With this in mind, you would have to agree that |
Correct. blueimp-load-image can detect if the browser does auto-orientation (with this code), but it cannot prevent it, only reset it by doing an inverse rotation.
I think useful settings depend on what you want to achieve, see e.g. a list of useful Options for image orientation here: |
Thanks for your explanation. Much appreciated.
I think the idea is to be able to 1) resize image on client side, 2) without affecting original image orientation, and without affecting original EXIF. Thus to handle image orientation either from browser/CSS, or from the app backend. From your suggestions, that leads to combo #4:
I have tried this using latest 10.30.0, but it yields the same result as setting Here is an image with EXIF rotation (download original). For reference, this is what the original looks like in modern browser, correctly oriented by browser based on the image's EXIF orientation: If I set CSS So, the idea is basically to upload that image, resized, without affecting orientation in any way. When I upload with Here is the uploaded version in browser. With the browser now orienting the image based on EXIF, the orientation is now wrong: If I set CSS This of course is not the expected behavior. We would like to keep the uploaded image orientation identical to the original. Furthermore, in this case, the image's EXIF orientation value is now wrong (because the image has been rotated, yet the EXIF orientation remains the same). This if course makes it impossible to anticipate anything when further processing the image: We can't use the EXIF value when creating server-resized versions of the upload, and the only safe way to display the original image, would be to set CSS That leaves the now flawless option of This of course means there will not be any problems whatsoever creating resized images, or displaying the image in browser. In a dream scenario, one might have hoped that all images were always rotated correctly, and that EXIF orientation did not exist. That is not the case unfortunately. From the perspective of a gallery app, it therefore seems hopeless to even consider any other option than Your efforts are truly appreciated in this orientation-madness! |
I wrote out the examples without testing all combinations properly; I've updated the Orientation examples (and tested them all) and also released a patch version ( |
Works
Also works However, I would like to note that From a usability perspective, for most apps and today's browsers, I can only conclude the following:
imageForceResize: true CSS imageOrientation Anyway. Thanks again for top effort and great lib! Now all seems good, and I don't intend to steal more time |
Yeah, like I wrote above: blueimp-load-image tries to do the least amount of work and if you do not override the default options, it will simply load the image as is (as provided by the browser) and return it. If |
includebrasil commentedNov 7, 2019
Hello,
I saw some issues with rotating images after uploading, and realized that most are old issues! I have the same problem, I need to insert some code snippet or just the setting that exists in the script is enough. I use the default script setting.
I honestly do not know what to do!
In the script example the image appears normal:
https://monosnap.com/file/aKGbooVXUWKXGeiP1i2UXVVAa470l1
In my script the image is rotated:
https://monosnap.com/file/ofrTpAIDXWvUNMxhmuNy0CSu1YUsVD
Any suggestion?
The text was updated successfully, but these errors were encountered: