Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Setting image orientation exif data using imagemagick

I have a set of images with corrupt exif orientation data. I would like to change the orientation of these images using imagemagick. I found the following command mogrify -set "%[EXIF:Orientation]" BottomRight image.jpg but it does not seem to work when I inspect the image using Identify -verbose image.jpg the orientation data is Undefined.

like image 921
Pablo Jomer Avatar asked Oct 15 '25 19:10

Pablo Jomer


2 Answers

Not sure if/how you can do that with ImageMagick, but you might like to use exiftool as follows:

# Set orientation with exiftool
exiftool -Orientation=3 -n input.jpg
1 image files updated

# Check with **ImageMagick** 
identify -verbose input.jpg | grep rient
Orientation: BottomRight
exif:Orientation: 3

Here is a little loop to test all 8 values:

for x in {1..8}; do 
   exiftool -Orientation=$x -n input.jpg > /dev/null
   identify -verbose input.jpg | grep Orientation
done

  Orientation: TopLeft
    exif:Orientation: 1
  Orientation: TopRight
    exif:Orientation: 2
  Orientation: BottomRight
    exif:Orientation: 3
  Orientation: BottomLeft
    exif:Orientation: 4
  Orientation: LeftTop
    exif:Orientation: 5
  Orientation: RightTop
    exif:Orientation: 6
  Orientation: RightBottom
    exif:Orientation: 7
  Orientation: LeftBottom
    exif:Orientation: 8
like image 115
Mark Setchell Avatar answered Oct 19 '25 04:10

Mark Setchell


With ImageMagick you can do it in the following way:

mogrify -orient <orientation> *.jpg

Valid orientations are

bottom-left    
right-top
bottom-right   
top-left
left-bottom    
top-right
left-top       
undefined
right-bottom 

More info here.

You can use identify to validate your change:

identify -verbose input.jpg | grep Orientation

like image 39
Pablo Jomer Avatar answered Oct 19 '25 02:10

Pablo Jomer



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!