Needs work
Project:
EXIF Orientation
Version:
8.x-1.x-dev
Component:
Code
Priority:
Major
Category:
Bug report
Assigned:
Unassigned
Reporter:
Created:
30 Sep 2024 at 20:58 UTC
Updated:
28 Apr 2026 at 12:15 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #2
adamps commentedComment #4
adamps commentedComment #5
msielskiFound this issue via issue #3401578. I'm not able to use the solution here because of the change from using hook_file_presave to only using a form alter. In my use case, images are created via another module (media_acquiadam, but I imagine any situation where images come in via an API would be affected), so the form alter approach gets skipped while the the hook_file_presave approach would work.
Comment #6
staalex commentedHere's a patch for this MR which adds support for the imagick toolkit, if you find it useful.
Comment #7
adamps commented@msielski Yes you are right, good point.
@staalex Thanks
Comment #9
greenskin commentedMade a merge request into the 3477919-overall-combined-fix branch that adds the `hook_file_presave()` hook back in (applies orientation changes in cases where the upload validation isn't applicable), and fixes an issue where the orientation value doesn't get removed for orientations other than 5, 6, 7, and 8.
See 3477919-overall_combined_fix-tweaks
Comment #11
tostinni commented@greenskin, adding back the
exif_orientation_file_presave()fixed a bug that we had where the exif rotation wasn't working when adding an image through the media library, so I'm adding this in the main MR.For the other part regarding fixing "the orientation value doesn't get removed for orientations" can you describe how to test it ?
I haven't added it for the moment, and if it's needed then we should also patch the GD part in
src/Plugin/ImageToolkit/Operation/gd/AutoOrient.phpComment #12
greenskin commented@tostinni, as I recall the
$this->addArguments(['-auto-orient']);did auto orient the image but without the exif orientation information removed, the browser was orienting the image again when viewing. I believe I specifically ran into this issue when images were converted to webp (via WebP module).Comment #13
solideogloria commentedComment #14
solideogloria commentedAfter looking at the comments, the status should've been set back to Needs Review.
Comment #15
nathaniel commentedThis fixes "The selected image handling toolkit 'imagemagick' can not process operation 'rotate'." and works with the photos / plupload modules.
Comment #19
dieterholvoet commentedThis solution works well for
gdandimagemagick toolkits, but not for other (remote) toolkits like Imgix and Bunny Optimizer. Why don't we hardcode thegdtoolkit for performing the rotation to the original image? It's a required PHP extension for Drupal so we can assume it's always present. This way the process doesn't break when sites are using other toolkits for creating image derivatives. Or at least make it configurable what toolkit is used.Comment #20
dieterholvoet commentedAs an extra I also added a Drush command to rotate all existing images.
Comment #21
solideogloria commentedThis sounds like a good solution, since gd is required. Is that something you could add to the MR?
Comment #22
dieterholvoet commentedI did! Not configurable for now though.
Comment #23
dieterholvoet commentedNever mind, forgot to push. Will add now.
Comment #24
solideogloria commentedI would add a comment about why
gdis hardcoded there.Comment #25
dieterholvoet commentedI was just wondering, in the gd
ImageToolkitOperation, where exactly is theOrientationtag being removed from the EXIF data? If this is a side effect of the rotate operation or imageflip call we should probably document it and make sure that the tag is removed anytime it's set. Currently, it's not being removed when its value is 1 for example.Comment #26
dieterholvoet commentedI checked and rotating the image with GD seems to also remove the
Orientationtag:I'll add a comment explaining this and update the tests as well.
Comment #27
dieterholvoet commentedComment #28
hidehisa commented@dieterholvoet Thank you for your work!
I wonder if it will be better to return false when image is not rotated to avoid unneeded file operation?
In
\Drupal\exif_orientation\Plugin\ImageToolkit\Operation\gd\AutoOrientplugin:Forget this if is pointless or wrong.