Page 1 of 1

Getting correct image width and height

Posted: 2016-08-03T09:53:53-07:00
by Masejoer
Another topic - I'm having issues getting consistent width and height values using "convert -format". I've noticed that the same image on Windows 7, Windows 10, and Ubuntu reports different widths and heights. One environment may report portrait dimensions while another reports landscape dimensions. When I view a bunch of images in a web browser, they are always in landscape mode, but many times IM is giving me portrait dimensions. Is there a consistent way to get width and height from an image, with images generated from a variety of devices?

I'm running ImageMagick-7.0.1-6 Q16-x64 on Windows (.bat) and 7.0.2-5 Q16-x64 on Ubuntu (.sh).

Code: Select all

convert input.jpg -format "%w %h" info:

Re: Getting correct image width and height

Posted: 2016-08-03T09:58:19-07:00
by snibgo
Masejoer wrote:I've noticed that the same image on Windows 7, Windows 10, and Ubuntu reports different widths and heights.
Please supply an example file that has this problem.

Re: Getting correct image width and height

Posted: 2016-08-03T10:07:45-07:00
by fmw42
Also how did you determine the heights? What IM command?

Re: Getting correct image width and height

Posted: 2016-08-09T11:28:04-07:00
by Masejoer
snibgo wrote:
Masejoer wrote:I've noticed that the same image on Windows 7, Windows 10, and Ubuntu reports different widths and heights.
Please supply an example file that has this problem.
Got a new photo. I had to get one without identifying information.

This was taken with an iPhone. It shows different orientation in different environments. Because of this, sometimes IM shows portrait data while a PC and web browser shows landscape, and vice versa.

http://www.masejoer.com/Images/IM/B3B9E ... BC4E21.jpg

Re: Getting correct image width and height

Posted: 2016-08-09T11:29:56-07:00
by Masejoer
fmw42 wrote:Also how did you determine the heights? What IM command?

Code: Select all

read -r WW HH <<< $( convert ./input.jpg -format "%w %h" info:) `#Get width and height of image` 

Re: Getting correct image width and height

Posted: 2016-08-09T13:05:02-07:00
by snibgo
The image is wider than it is tall. IM should always say this. Does it ever say anything else?

The image also has metadata that says "display this rotated 90 degrees clockwise". Some software obeys this; some doesn't.