rokka-io / imagine-vips

libvips adapter for php imagine
https://rokka.io
Other
41 stars 8 forks source link

Can't disable automatic image rotation #20

Open fbourigault opened 3 years ago

fbourigault commented 3 years ago

Hello,

Given a photo with exif-ifd0-Orientation: 6. If I load the image like the code below, the thumbnail.jpg file is rotated.

I would like to know if it's a mistake in the array_merge arguments order in https://github.com/rokka-io/imagine-vips/blob/master/lib/Imagine/Vips/Imagine.php#L209?

Also, I would like to know if there is a reason to have automatic rotation enabled?

I spotted this issue while replacing Gd by Vips in the project I work on. Because when a picture is loaded with automatic rotation, the orientation related metadata is not reset leading to the Autorotate transformation applying the rotation an other time.

<?php

use Imagine\Image\Box;
use Imagine\Vips\Imagine;

require __DIR__.'/vendor/autoload.php';

$imagine = new Imagine();

$image = $imagine->open(__DIR__.'/DSC_3513.JPG', ['autorotate' => false]);

$thumbnail = $image->thumbnail(new Box(300, 300));

$thumbnail->save(__DIR__.'/thumbnail.jpg');
ethaniel commented 1 year ago

I have the same problem. Yes, it is surely because of a mistake in the array_merge arguments order. @chregu, can you kindly look into this? This looks like a one line fix.

$options = array_merge($loadOptions, $options); needs to be $options = array_merge($options,$loadOptions);, so the users could overwrite the autorotate option.