-
Notifications
You must be signed in to change notification settings - Fork 70
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
Saved product images are rotated 90 degrees counterclockwise #334
Comments
Is this related to PHP GD or Imagick library? |
Unsure. The online discussions I found suggested neither library automatically rotates images. Most posts I found described writing a custom function to rotate images. I could not find anything regarding GD for auto rotations but Imagick in particular appears to have support to auto rotate in their command line tool but it seems as though you have to manually call it in code to apply the same effect. I was attempting to inject my own code with a vmod that used GD to rotate the image but was unsuccessful doing so, and I was unable to determine how the image is being queried and processed after saving the product to rule out if this was something that occurred before or after the image was saved to the database. |
With GD you can try something like this:
And for Imagick:
Thank you ChatGPT |
Description
What were you trying to do?
Create products and upload pictures taken with my phone (picture used for testing). The steps I did are as follows:
What actually happened?
When I upload a picture (taken with a digital camera) to a product, its orientation looks correct. However, when I save a product, the picture is rotated 90 degrees counterclockwise. This is also the case for its thumbnail and how it appears in store pages.
What did you expect to happen?
I expected the picture to remain the same orientation as I uploaded it. The image looks correct in my phone gallery and desktop apps I've sent it to. There don't appear to be any settings that influence the orientation of the image itself. My own research suggests that the EXIF orientation tag for images captured with a digital camera isn't being considered in LiteCart to the image after upload. It is unclear when the problem occurs as my own attempts to fix image rotation before it's stored in the database haven't worked.
Using InfraView, I confirmed the image correctly has orientation flag 1 for a portrait picture. When this flag is not considered, the image is rotated the same in InfraView as it is in LiteCart.
Workarounds?
I found two forum posts that appear to be related. Based on these posts, it seems like I should be able to resave the image on my desktop but trying to save it with Windows Photos failed to fix it and stripping the EXIF data from "Properties > Details" didn't seem to work either. What has worked for me is taking an uploaded file to a third-party app (i.e. Discord) and saving that file instead.
LiteCart Version
LiteCart 2.5.5
PHP Version
PHP 8.2
Error/Backtrace
No response
Is this a problem that can be reproduced in the demo platform?
Yes
If this problem could be related to a browser. Which one?
Firefox
The text was updated successfully, but these errors were encountered: