Page 1 of 1
ImageMagick convert rotates images during resize
Posted: 2018-04-22T10:47:42-07:00
by Stubb
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?
Re: ImageMagick convert rotates images during resize
Posted: 2018-04-22T11:02:27-07:00
by Bonzo
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
Re: ImageMagick convert rotates images during resize
Posted: 2018-04-22T11:05:37-07:00
by Stubb
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
Re: ImageMagick convert rotates images during resize
Posted: 2018-04-22T11:05:50-07:00
by snibgo
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
Re: ImageMagick convert rotates images during resize
Posted: 2018-04-22T11:15:29-07:00
by Stubb
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…
Re: ImageMagick convert rotates images during resize
Posted: 2018-04-22T14:33:01-07:00
by fmw42
try adding -auto-orient to your command
Code: Select all
convert -auto-orient 2018-04-11-0001.jpg -resize 172x172" ...
Re: ImageMagick convert rotates images during resize
Posted: 2018-04-22T15:08:51-07:00
by Stubb
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>