Wrong image orientation recognition

Post any defects you find in the released or beta versions of the ImageMagick software here. Include the ImageMagick version, OS, and any command-line required to reproduce the problem. Got a patch for a bug? Post it here.
Post Reply
dmitry_torba
Posts: 2
Joined: 2016-07-05T15:58:39-07:00
Authentication code: 1151

Wrong image orientation recognition

Post 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.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Wrong image orientation recognition

Post 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
dmitry_torba
Posts: 2
Joined: 2016-07-05T15:58:39-07:00
Authentication code: 1151

Re: Wrong image orientation recognition

Post by dmitry_torba »

The problem shows up in the libraries that use image magic as an engine. like intervention PHP library.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Wrong image orientation recognition

Post by fmw42 »

I am not familiar with those libraries, but they need to use -auto-orient to get the correct orientation.
indjeto
Posts: 5
Joined: 2016-07-03T07:54:20-07:00
Authentication code: 1151

Re: Wrong image orientation recognition

Post 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;
Post Reply