snibgo wrote:I'm not sure what you are asking. exiftool reports:
Code: Select all
XMP-tiff:Orientation='Rotate 90 CW'
Yep, exiftool does report the orientation, but for the sake of consistency, I want to extract the orientation using ImageMagick tools, so that the value I'm extracting is consistent with what "convert" uses when I later use -auto-orient when converting the image to another size.
A decription of our upload flow might help here. When a user uploads an image, we store the uploaded image as-is, and we also extract the width and height of the image, to store in our database. We also extract orientation (currently using "identify -format '%[EXIF:Orientation]'"), and if the orientation is one that involves a rotaion, we swap the width and height before storing them, so that the dimensions we store in our database match the image's true orientation.
When we serve the image on our site, we use resize the image to our desired size using convert, with the -auto-orient and -strip flags to re-orient the image and then remove its orientation data, if necessary. We need to know what size the image will be before we resize it, though, so that we can write the dimensions in to the page; the image is generated on-the-fly after the page has been rendered.
Right now, because we can't reliably extract the orientation, we sometimes display images with the wrong width and height in their img tags on the page. I could use another tool, like eximtool, to extract the orientation, but if there's ever a mismatch between what exiftool reports and what "convert -auto-orient" acts on, then I'll just end up back in the same situation.
I seems that I can extract the orientation using "identify -verbose", but this extracts a bunch of other things I don't need, and takes a noticeable amount of CPU time doing it, so I'd like to avoid it if possible.