Many cameras create a photo file with originally portrait orientation by
capturing it pyhsically in landscape mode and create header tag that it is rotated by 90 (or 270 deg).
When such a *.jpg file is opened in a (most) picture viewer, then the picture viewer reads at first the orientation header tag and displays the photo in correct view.
Now, how can I read with ImageMagick from (DOS batch) script file the orientation value from *.jpg header?
Later I want to implement something like
set orient = convert -showorientation mysample.jpg
if orient=90 (jpegtran -rotate 270 mysample.jpg mysampleout.jpg)
In other words: I want to convert the virtual orientation into a physical one.
What I need is the ImageMagick command to get the orientation angle from Jpg header.
Thank you
Ben
How to find out if a *.jpg is currently rotated?
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: How to find out if a *.jpg is currently rotated?
ImageMagick will auto-orient your image for you when you read it. See -auto-orient at https://imagemagick.org/script/command- ... uto-orient.
You can get the orientation flag from the head using -format "%[EXIF:orientation]" info:, if it exists in the header. See % escapes at https://imagemagick.org/script/escape.php. There are tables that correspond the flags with the orientation/rotation. See https://www.impulseadventure.com/photo/ ... ation.html and https://magnushoff.com/jpeg-orientation.html or search Google.
You can get the orientation flag from the head using -format "%[EXIF:orientation]" info:, if it exists in the header. See % escapes at https://imagemagick.org/script/escape.php. There are tables that correspond the flags with the orientation/rotation. See https://www.impulseadventure.com/photo/ ... ation.html and https://magnushoff.com/jpeg-orientation.html or search Google.
-
- Posts: 12159
- Joined: 2010-01-23T23:01:33-07:00
- Authentication code: 1151
- Location: England, UK
Re: How to find out if a *.jpg is currently rotated?
What version of IM, on what platform?
See "orientation" on http://www.imagemagick.org/script/escape.php
See also http://www.imagemagick.org/script/comma ... uto-orient and Orientation.
See "orientation" on http://www.imagemagick.org/script/escape.php
Code: Select all
magick or_1.jpg -format %[orientation] info:
TopLeft
snibgo's IM pages: im.snibgo.com