Bug #69274
closedPortrait Images rotated while file processing
Added by Philipp Wrann over 9 years ago. Updated about 6 years ago.
100%
Description
Many cameras today save pictures not rotated when making a portrait, they save it with some exif meta tag that turns the image in preview mode (90|180|270 deg).
Typo3 should take this into account after uploading. One of my customer has to rotate many pictures in preview program of OS to make it appear correctly in TYPO3.
Either rotate the image:
Imagemagicks convert has some -auto-orient option, that should do the job.
Here is some resource:
http://stackoverflow.com/questions/19456036/detect-exif-orientation-and-rotate-image-using-imagemagick
Or take the exif-information simply into account in all places and provide optionally a button to reset it (like in preview programs).
Files
Exif Left Bottom Test Image.JPG (1.02 MB) Exif Left Bottom Test Image.JPG | Markus Klein, 2018-05-18 15:45 |
Updated by Xavier Perseguers over 9 years ago
- Status changed from New to Rejected
This is not a bug, when you upload an image, the Core of TYPO3 should not do any magick because changing the orientation modifies the actual image you uploaded.
However, there is an easy solution for that, just install EXT:image_autoresize from TER and it will do exactly that (if you don't want to reduce size of uploaded images at all - why?) then just put some very high size threshold in the configuration.
Updated by Philipp Wrann over 9 years ago
I will have a look at that extension but why would it be so bad to include some functionality in the core? Or to simply make use of the orientation exif information?
At the moment you upload a portrait image (taken from iphone) and the image is displayed rotated - if the exif orientation is set it should be taken into account when creating processed images, dont you think?
IMO this should really work out of the box.
So okay - imagemagick convert is no solution - but taking the exif rotate property into account when dealing with images IS.
Updated by Christiaan Wiesenekker about 9 years ago
I think Philipp Wrann is totally right. Ignoring the orientation IS doing magic to the original file... TYPO3 core should respect the exif's
Updated by Mr Fondolz over 8 years ago
Why was this bug rejected? It is an issue how typo3 is using image magick. It should be atleast a setting in the [GFX] part of the installer. Using or developing an extension for this basic functionallity is too much....
I currently use the option [GFX][im_useStripProfileByDefault] so i can use [GFX][im_stripProfileCommand] with "-auto-orient +profile '*'" and every uploaded image will be fine.
Updated by Xavier Perseguers over 8 years ago
For the record, ImageMagick is known to be much more vulnerable than GraphicsMagick and you may have a look into the code from EXT:image_autoresize how I had to handle the reorientation when using GM, this is not a simple flag as in IM. Furthermore, this is definitely magick to modify the file when uploading. Taking the EXIF orientation into account, when displaying the image, is not the same as changing the file. When you rotate the picture, you are potentially changing its quality as well, since the pattern in JPEG chunks are not the same anymore.
Long story short, there are a few easy solutions that you came with:
- Install EXT:image_autoresize
- Modify the
im_useStripProfileByDefault
setting which works fine if you use IM
I don't see a need to do anything else in the Core.
Updated by Stefan Froemken over 8 years ago
- Subject changed from Portrait Images rotated after uploading to Portrait Images rotated while file processing
- Status changed from Rejected to Accepted
- Assignee set to Stefan Froemken
- Target version changed from 7.5 to 7.6.5
- PHP Version set to 5.6
- Complexity set to easy
As already told, we will not modify any file while upload.
But we can modify the thumb and image generation for Backend and Frontend.
I have changed the title and will create a new patch to add the new option in Installtool
Updated by Gerrit Code Review over 8 years ago
- Status changed from Accepted to Under Review
Patch set 1 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/48079
Updated by Gerrit Code Review over 8 years ago
Patch set 2 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/48079
Updated by Benni Mack over 8 years ago
- Target version changed from 7.6.5 to Candidate for patchlevel
Updated by Deleted Account over 8 years ago
Setting -auto-orient alone will only partially fix this issue, because the width/height calculation for image resizing still ignores the EXIF rotation.
Replacing calls to the PHP function getimagesize with a custom function would fix the problem:
class ImageUtility { /** * @param string $imageFile * * @return array */ public static function getImageSize($imageFile) { $size = @getimagesize($imageFile); if ($size === FALSE) { return FALSE; } $exif = @exif_read_data($imageFile); $width = $size[ 0 ]; $height = $size[ 1 ]; // see: http://sylvana.net/jpegcrop/exif_orientation.html if (isset($exif[ 'Orientation' ]) && $exif[ 'Orientation' ] >= 5 && $exif[ 'Orientation' ] <= 8) { return [$height, $width]; } return [$width, $height]; } }
I have experimented with an extension that overrides the following methods from the core:
(only replaces calls to getimagesize with the function shown above)
- \TYPO3\CMS\Core\Imaging\GraphicalFunctions->getImageDimensions
- \TYPO3\CMS\Core\Imaging\GraphicalFunctions->imageCreateFromFile
- \TYPO3\CMS\Core\Type\File\ImageInfo->getImageSizes
and the images seem to be processed correctly.
Updated by Markus Klösges over 7 years ago
I also got caught by this. Exif rotation is applied if the corresponding flag is set in LocalConfiguration, but using such a rotated file inside of GIFBUILDER leads to wrong output dimensions. @Ruben, I tried your solution without luck, do you have any newer input on that issue?
Updated by Deleted Account about 7 years ago
@Markus Since posting that comment I have fixing the behavior of the image processing might not be the best solution.
(Browsers display images with an EXIF orientation incorrectly so we would have to process all those images to make sure the images are displayed properly.)
( Shameless self-advertising ahead ;-) )
However, I did create an extension that creates a button to "apply" the EXIF orientation on such images: https://github.com/bash/exif_orientation_helper
Updated by Gerrit Code Review about 7 years ago
Patch set 3 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/48079
Updated by Gerrit Code Review about 7 years ago
Patch set 4 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/48079
Updated by Gerrit Code Review about 7 years ago
Patch set 5 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/48079
Updated by Riccardo De Contardi about 7 years ago
- Related to Bug #61655: Image rescaling breaks/ignores exif orientation added
Updated by Gerrit Code Review about 7 years ago
Patch set 6 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/48079
Updated by Tomas Norre Mikkelsen about 7 years ago
I've been considering this issue.. and from my point of view this is a task for the editors not for the CMS.. Of course it would be nice if the system supports the editors, but images are always a little sensitive topic.
It's content and it has to be verified by the Editor anyway.. I wouldn't invest more time in this.
I would reject this issue.
Updated by Markus Timtner about 7 years ago
At least the image editing tool should offer the option to rotate images -
it is something a user would expect if a tool calls itself image "editor"
Nearly all of my editors are complaining about the missing rotation option.
(or the image editing tool should be called "cropping tool" otherwise.)
@#12 Ruben Schmidmeister
Thank you very much for your work, will have a look into that.
Updated by Gerrit Code Review over 6 years ago
Patch set 7 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/48079
Updated by Gerrit Code Review over 6 years ago
Patch set 8 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/48079
Updated by Gerrit Code Review over 6 years ago
Patch set 9 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/48079
Updated by Mathias Brodala over 6 years ago
- Sprint Focus deleted (
On Location Sprint)
Updated by Gerrit Code Review over 6 years ago
Patch set 10 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/48079
Updated by Gerrit Code Review over 6 years ago
Patch set 11 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/48079
Updated by Gerrit Code Review over 6 years ago
Patch set 12 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/48079
Updated by Markus Klein over 6 years ago
- File Exif Left Bottom Test Image.JPG Exif Left Bottom Test Image.JPG added
- Target version deleted (
Candidate for patchlevel)
Updated by Stefan Froemken over 6 years ago
- Status changed from Under Review to Resolved
- % Done changed from 0 to 100
Applied in changeset 5179ff93181cf85bf5e401da63e1194b0a25716e.
Updated by Torben Hansen about 1 year ago
- Related to Task #101922: Suggest php exif module in system environment status added