Issue with product image keeps rotating
Forum rules
Always add your Aimeos and PHP version as well as your environment (Linux/Mac/Win)
Spam and unrelated posts will be removed immediately!
Always add your Aimeos and PHP version as well as your environment (Linux/Mac/Win)
Spam and unrelated posts will be removed immediately!
Issue with product image keeps rotating
Hello,
I'm a new Aimeos (Laravel version) user and I'm starting to really love it and the way it's been put together.
There are few things that took me a while to grasp, but I'm getting there.
Now, when it comes to the issue that I'm having now, it's one with product image upload.
I have consulted documentation and did a lot of testing and playing around with settings, no matter what I do and what type of settings I pass along in:
Rotation is 90 degrees counterclockwise.
I would like to point out that PREVIEW image (first one that shows once image is uploaded) is fine.
Rotating occurs once when "Save" button is clicked and action performed.
Is there option in the media processing part or controller.php that just can say "do not rotate images". Do resizing and whatever is needed, but stop rotating.
Image size (if it matters):
Width: 2604
Height: 4624
If image goes trough Photoshop and is saved, it does not keep rotating. If it is downloaded from IG (for example) and uploaded it does not rotate. One really really odd situation or possible bug.
Any input is appreciated. Thanks all for reading and help!
Aimeos 2022.10+ (2022.10.3)
PHP 8.1.12
Win
I'm a new Aimeos (Laravel version) user and I'm starting to really love it and the way it's been put together.
There are few things that took me a while to grasp, but I'm getting there.
Now, when it comes to the issue that I'm having now, it's one with product image upload.
I have consulted documentation and did a lot of testing and playing around with settings, no matter what I do and what type of settings I pass along in:
Image taken directly from phone keeps getting ROTATED. Resizing is done properly, everything that I set in options is being applied, only highly annoying thing is that image keeps ROTATING.vendor/aimeos/aimeos-core/config/controller.php
Rotation is 90 degrees counterclockwise.
I would like to point out that PREVIEW image (first one that shows once image is uploaded) is fine.
Rotating occurs once when "Save" button is clicked and action performed.
Is there option in the media processing part or controller.php that just can say "do not rotate images". Do resizing and whatever is needed, but stop rotating.
Image size (if it matters):
Width: 2604
Height: 4624
If image goes trough Photoshop and is saved, it does not keep rotating. If it is downloaded from IG (for example) and uploaded it does not rotate. One really really odd situation or possible bug.
Any input is appreciated. Thanks all for reading and help!
Aimeos 2022.10+ (2022.10.3)
PHP 8.1.12
Win
============================
Aimeos 2022.10+ (2022.10.3)
PHP 8.1.12 / Laravel
Win (Develop)
Aimeos 2022.10+ (2022.10.3)
PHP 8.1.12 / Laravel
Win (Develop)
Re: Issue with product image keeps rotating
Hm, Aimeos doesn't implement rotating images at all, only resizing and cropping can be done.
Maybe it's something that is done by Imagemagick automatically?
Here's the source code for image handling:
https://github.com/aimeos/aimeos-core/b ... magick.php
Maybe it's something that is done by Imagemagick automatically?
Here's the source code for image handling:
https://github.com/aimeos/aimeos-core/b ... magick.php
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, give us a star
If you like Aimeos, give us a star
Re: Issue with product image keeps rotating
Thanks for your reply. Yes that seems to be the case.
Here is one very old post, but it does explain this type of behavior and helped me with further research.
I have just read EXIF of one of the uploaded files and indeed it says clearly:
It seems to me that photo is taken horizontally with instructions to rotate it 90 CW written in EXIF that seems not to be applied when process is completed.
Imagick.php that handles images does not take this into consideration and it actually uses image "as is" (horizontal) without this instruction to rotate it 90 CW. However, preview image does use it and applies rotate 90 CW to the image properly.
Here is one very old post, but it does explain this type of behavior and helped me with further research.
I have just read EXIF of one of the uploaded files and indeed it says clearly:
Code: Select all
Orientation: Rotate 90 CW
Imagick.php that handles images does not take this into consideration and it actually uses image "as is" (horizontal) without this instruction to rotate it 90 CW. However, preview image does use it and applies rotate 90 CW to the image properly.
============================
Aimeos 2022.10+ (2022.10.3)
PHP 8.1.12 / Laravel
Win (Develop)
Aimeos 2022.10+ (2022.10.3)
PHP 8.1.12 / Laravel
Win (Develop)
Re: Issue with product image keeps rotating
Quick update.
I have done a quick test. Updating this code here:
https://github.com/aimeos/aimeos-core/b ... k.php#L129
Inserting:
Solves issue for our use case. I will do other cases as well, but this was just a quick test and it works.
Ref:
https://www.php.net/manual/en/imagick.g ... php#111448
https://exiftool.org/forum/index.php?topic=7909.0
I have done a quick test. Updating this code here:
https://github.com/aimeos/aimeos-core/b ... k.php#L129
Inserting:
Code: Select all
$orientation = $this->image->getImageOrientation();
switch($orientation) {
case 6:
$this->image->rotateImage("#fff", 90); // rotate 90 degrees CW
break;
}
// Now that it's auto-rotated, make sure the EXIF data is correct in case the EXIF gets saved with the image!
$this->image->setImageOrientation(1);
Ref:
https://www.php.net/manual/en/imagick.g ... php#111448
https://exiftool.org/forum/index.php?topic=7909.0
============================
Aimeos 2022.10+ (2022.10.3)
PHP 8.1.12 / Laravel
Win (Develop)
Aimeos 2022.10+ (2022.10.3)
PHP 8.1.12 / Laravel
Win (Develop)
Re: Issue with product image keeps rotating
Very cool and eager to get a PR from you solving that issue!
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, give us a star
If you like Aimeos, give us a star
Re: Issue with product image keeps rotating
Thanks for checking it out and confirming that this is a right place to do so! Will do as soon as I sort it out.
============================
Aimeos 2022.10+ (2022.10.3)
PHP 8.1.12 / Laravel
Win (Develop)
Aimeos 2022.10+ (2022.10.3)
PHP 8.1.12 / Laravel
Win (Develop)