ImageMagick convert rotates images during resize

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
User avatar
Stubb
Posts: 4
Joined: 2018-04-22T10:31:58-07:00
Authentication code: 1152
Location: Atlanta, GA

ImageMagick convert rotates images during resize

Post by Stubb » 2018-04-22T10:47:42-07:00

I'm running ImageMagick 6.9.9-26 Q16 x86_64 2018-03-27 on MacOS installed via MacPorts.

Doing "convert 2018-04-11-0001.jpg -resize 172x172" on the attached image (960x1280) results in an image that's resulted 90° (172x129, should be 129x172).

Any obvious reason that this is happening?

Image
Last edited by Stubb on 2018-04-22T11:44:27-07:00, edited 1 time in total.

Bonzo
Posts: 2969
Joined: 2006-05-20T08:08:19-07:00
Location: Cambridge, England

Re: ImageMagick convert rotates images during resize

Post by Bonzo » 2018-04-22T11:02:27-07:00

It is never good to have - in an image name. I always use _ instead.

Try enclosing your image in " " e.g. convert "2018-04-11-0001.jpg" -resize 172x172

User avatar
Stubb
Posts: 4
Joined: 2018-04-22T10:31:58-07:00
Authentication code: 1152
Location: Atlanta, GA

Re: ImageMagick convert rotates images during resize

Post by Stubb » 2018-04-22T11:05:37-07:00

Bonzo wrote:
2018-04-22T11:02:27-07:00
It is never good to have - in an image name. I always use _ instead.

Try enclosing your image in " " e.g. convert "2018-04-11-0001.jpg" -resize 172x172
I'm getting the same 90% rotation regardless of the filename 😕

snibgo
Posts: 10717
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: ImageMagick convert rotates images during resize

Post by snibgo » 2018-04-22T11:05:50-07:00

The input image is 960x1280, and the result of the resize (with IM v6.9.5-3) is 129x172. However, both images contain metadata "Orientation: 6", which tells viewers to rotate the image by 90 degrees.

The camera was held vertically to take the photo, and metadata correctly recorded this. Then some software rotated the image to make it vertical but without also changing the metadata, so some viewers will rotate it again.

A workaround is to correct the metadata:

Code: Select all

exiftool -n -Orientation=0 abcd.jpg
snibgo's IM pages: im.snibgo.com

User avatar
Stubb
Posts: 4
Joined: 2018-04-22T10:31:58-07:00
Authentication code: 1152
Location: Atlanta, GA

Re: ImageMagick convert rotates images during resize

Post by Stubb » 2018-04-22T11:15:29-07:00

snibgo wrote:
2018-04-22T11:05:50-07:00
The camera was held vertically to take the photo, and metadata correctly recorded this. Then some software rotated the image to make it vertical but without also changing the metadata, so some viewers will rotate it again.
Very interesting. I'm tracing the image through my workflow (Photo Supreme for cataloging, DxO Photolab for editing) to see where the problem occurs…

User avatar
fmw42
Posts: 23880
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: ImageMagick convert rotates images during resize

Post by fmw42 » 2018-04-22T14:33:01-07:00

try adding -auto-orient to your command

Code: Select all

convert -auto-orient 2018-04-11-0001.jpg -resize 172x172" ...

User avatar
Stubb
Posts: 4
Joined: 2018-04-22T10:31:58-07:00
Authentication code: 1152
Location: Atlanta, GA

Re: ImageMagick convert rotates images during resize

Post by Stubb » 2018-04-22T15:08:51-07:00

fmw42 wrote:
2018-04-22T14:33:01-07:00
try adding -auto-orient to your command

Code: Select all

convert -auto-orient 2018-04-11-0001.jpg -resize 172x172" ...
That doesn't seem to do the trick.

I've presently added a post-resize command to my script:

Code: Select all

exiftool -P -overwrite_original_in_place -Orientation=0 -n <thumbnail file>

Post Reply