image icon indicating copy to clipboard operation
image copied to clipboard

Automatic or manual rotation of the image according to EXIF orientation

Open olivervogel opened this issue 1 year ago • 3 comments

Images can contain EXIF information for camera rotation. This information is read by Intervention Image and an alignment (rotation) is performed based on it. Since version 3 this happens automatically when new image instances are decoded. In version 2, the orientation had to be triggered manually using the orientate() method.

While this may seem convenient, it may not always be desirable. Especially for very large image formats, rotation can consume alot of memory and processing time, which is not always utilized. See #1278

A return to manual auto-alignment after EXIF camera rotation should be discussed.

Keep in mind that a return to manual, will be a breaking change.

What do you think?

olivervogel avatar Jan 28 '24 08:01 olivervogel

I'm not very familiar with the internal codes of Intervention Image, but I think if you use a flag/option variable with a correct default value, you can keep current behavior and avoid breaking change. something like this:

$image = $manager->read($filePath, FilePathImageDecoder::class, false) read(mixed $input, string|array|DecoderInterface $decoders = [], bool $autoExifRotate = true) OR $image = $manager->read($filePath, FilePathImageDecoder::class, ['autoExifRotate' => false]) read(mixed $input, string|array|DecoderInterface $decoders = [], array $options= ['autoExifRotate' => true])

a-shafaat avatar Jan 28 '24 12:01 a-shafaat

+1 for this.

Elycin avatar Jan 30 '24 08:01 Elycin

Any updates on this, would love to have not autorotate my images.

sitenzo avatar May 05 '24 17:05 sitenzo

This feature is available from version 3.7.0.

As of this version, it is possible to configure the ImageManager globally. The autoOrientation option can be used to disable automatic exif alignment in the decoding process.

Example

use Intervention\Image\ImageManager;
use Intervention\Image\Drivers\Imagick\Driver;

// disable animation decoding in config
$manager = new ImageManager(
    Driver::class,
    autoOrientation: false // disable automatically alignment based on exif data.
);

// read image is not aligned ...
$image = $manager->read('test.jpg');

// ... but can be aligned manually at a later time
$image->orient();

See documentation for more details.

olivervogel avatar Jun 15 '24 08:06 olivervogel