Stop ImageMagick from rotating image on append

command lineimage manipulationimagemagickimages

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?

Best Answer

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.

Related Question