Page 1 of 1

Wrong image orientation recognition

Posted: 2016-07-05T16:11:35-07:00
by dmitry_torba
The following image should be in portrait orientation (it was taken with a phone as portrait image)

Image
http://files.torba.me/imagick_problem.jpg
(filled with a black rectangle using imagemagic convert to prevent recognition of people pictured

It is opened as portrait image in Windows and EXIF data viewers show that it should be portrait orientation. However, if I launch the following command:

Code: Select all

identify -format '%wx%h' 2.jpg 
It says

Code: Select all

5312x2988
That seems to be a bug with interpretation of Exif data.

Is it going to be fixed in the following version and is there any patch for that?

Thank you.

Re: Wrong image orientation recognition

Posted: 2016-07-05T18:05:19-07:00
by fmw42
You need to use -auto-orient in any IM convert of your images. And any viewers need to be able to read and rotate according to the EXIF data. Apparently this forum software is not EXIF aware.

This works just fine on IM 6.9.5.0 Q16 Mac OSX.

Code: Select all

convert imagick_problem.jpg -auto-orient -format "%wx%h" info:
2988x5312

Re: Wrong image orientation recognition

Posted: 2016-07-06T07:06:09-07:00
by dmitry_torba
The problem shows up in the libraries that use image magic as an engine. like intervention PHP library.

Re: Wrong image orientation recognition

Posted: 2016-07-06T09:15:38-07:00
by fmw42
I am not familiar with those libraries, but they need to use -auto-orient to get the correct orientation.

Re: Wrong image orientation recognition

Posted: 2016-07-08T12:41:36-07:00
by indjeto
I experienced the same problem with the php extension. (Todays last versions, compiled from source ; ImageMagick-7.0.2-2; php lib:imagick-3.4.3RC1)
I made this workaround:
Substitute

Code: Select all

$orientation = $image->getImageOrientation();
with

Code: Select all

$props = $image->getImageProperties('exif:Orientation', true);
$orientation = isset($props['exif:Orientation']) ? $props['exif:Orientation'] : null;