Sulu: Image rotation based on exif

Created on 1 Aug 2018  路  5Comments  路  Source: sulu/sulu

| Q | A
| --- | ---
| Bug? | no
| New Feature? | yes
| Sulu Version | <= 1.6.20, dev-develop
| Browser Version | All

Actual Behavior

Currently the ImagineImageConverter doesn't use the Autorotate filter which takes exif data into consideration. So images won't rotate based on the exif data.

Expected Behavior

Rotate images based on the orientation of the picture

Steps to Reproduce

Add an image which uses a different rotation then the "default top-left" (see the test image)

Possible Solutions

Hook into the ImagineImageConverter and always add the rotation filter.
test-image.zip

Bug

All 5 comments

seems like autorotate needs an additional PHP extension to read the exif data:

So think we will need to add the following:

private function autorotate(ImageInterface $image)
{
     if (!ExifMetadataReader:isSupported) { // EDIT: seems like this check is not needed as it is done internal by imagine
          return $image;
     }

     $autorotateFilter = new Autorotate();
     return $autorotateFilter->apply($image);
}

and call this function before the image is resized e.g. after toRgb function.

/cc @sulu/core-team think nothing speaks again to add this to the ImagineImageConverter?

@alexander-schranz If you say so :-) @MichelFalke Would you have time to provide a PR?

@danrot I will

@MichelFalke you still want to contribute this. Hacktoberfest is the best time for it ;)

this issue is fixed in 1.6.23

Was this page helpful?
0 / 5 - 0 ratings