7

I took two photos with my phone, one horizontal and one vertical, and they show up fine in Eye of Gnome. When I try to glue them top-to-bottom with ImageMagick's convert:

$ convert img1.jpg img2.jpg +append both.jpg

The horizontal one rotates to be vertical before being appended. The same thing happens if I make them side-by-side with the -append option.

How can I use convert to append one image to another without rotating them to be the same dimensions?

1 Answer 1

22

Try adding -auto-orient to the command you're running,

$ convert -auto-orient img1.jpg img2.jpg +append both.jpg

Your images have EXIF data telling your viewer which way to present them, but without -auto-orient, ImageMagick ignores that.

Think of it another way, how does anything know which way your camera was pointing when you took the image? Horizontal or vertical, it's all the same size and same number of pixels. The EXIF data tells viewers whether your camera was in a landscape or portrait orientation, and which way up it was, so it knows which way to show the image.

So you don't want to stop ImageMagick from rotating them, it's not rotating them, it's just not using the EXIF data to work out which way up your camera was and assuming everything is landscape or portrait. So you need to tell it to actually rotate the one that was shot in the non-default orientation. Hopefully, -auto-orient will achieve that.

3
  • 2
    It works, although it should be said it must be put at the beginning of the command: convert -auto-orient img1.jpg img2.jpg +append both.jpg. Commented Mar 4, 2016 at 18:25
  • This EXIF rotation data is misinterpreted by so many programs, that it would be much better if the camera simply saved the image in the correct orientation.
    – Rodrigo
    Commented Sep 21, 2020 at 21:21
  • Thank you so much.
    – theeranitp
    Commented Apr 5 at 10:02

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .