determining the pixel aspect ratio of a TIFF

Questions and postings pertaining to the usage of ImageMagick regardless of the interface. This includes the command-line utilities, as well as the C and C++ APIs. Usage questions are like "How do I use ImageMagick to create drop shadows?".
Post Reply
easyhtrees
Posts: 5
Joined: 2018-06-19T11:58:22-07:00
Authentication code: 1152

determining the pixel aspect ratio of a TIFF

Post by easyhtrees »

Hi there, this is a little out of my domain so please bear with me. I have a TIFF image coming out of an in house application and the issue seems to be that, while the size of the image is correct (1024 x 768), the pixel aspect ratio is not. How do I measure this using ImageMagick for Windows? I had heard this tool could do it, but I am not sure how. Thanks in advance.
Last edited by easyhtrees on 2018-06-19T12:41:55-07:00, edited 1 time in total.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: determining the pixel aspect ration of a TIFF

Post by fmw42 »

What do you mean by pixel aspect ratio? Do you mean the width/height ratio of the image where the width and height are in pixels? If so, then

Code: Select all

convert image.tiff -format "%[fx:w/h]\n" info:
If on IM 7, then use magick rather than convert.

____________________________

Please, always provide your IM version and platform when asking questions, since syntax may differ. Also provide your exact command line and if possible your images.

See the top-most post in this forum "IMPORTANT: Please Read This FIRST Before Posting" at http://www.imagemagick.org/discourse-se ... f=1&t=9620

For novices, see

http://www.imagemagick.org/discourse-se ... f=1&t=9620
http://www.imagemagick.org/script/comma ... essing.php
http://www.imagemagick.org/Usage/reference.html
http://www.imagemagick.org/Usage/
https://github.com/ImageMagick/usage-markdown
easyhtrees
Posts: 5
Joined: 2018-06-19T11:58:22-07:00
Authentication code: 1152

Re: determining the pixel aspect ration of a TIFF

Post by easyhtrees »

Thanks for the response. My understanding is that 'Pixel Aspect Ratio' refers to the ratio of the pixel's width to its height. I should clarify that the above doesn't give me that information.
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: determining the pixel aspect ratio of a TIFF

Post by snibgo »

easyhtrees wrote:How do I measure this using ImageMagick for Windows?
Please link to a sample TIFF with non-unity pixel aspect ratio. Then we can try a few things.
snibgo's IM pages: im.snibgo.com
easyhtrees
Posts: 5
Joined: 2018-06-19T11:58:22-07:00
Authentication code: 1152

Re: determining the pixel aspect ratio of a TIFF

Post by easyhtrees »

Here is an upload: https://imgur.com/hPq53nZ
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: determining the pixel aspect ratio of a TIFF

Post by snibgo »

You asked about TIFF, but the link is to a PNG?

"hPq53nZ - Imgur.png" seems to have square pixels.

But I've remembered how pixel aspect ratio is recorded: in the density. Square pixels (the normal situation) have equal densities in x and y. Non-square have unequal densities.
snibgo's IM pages: im.snibgo.com
easyhtrees
Posts: 5
Joined: 2018-06-19T11:58:22-07:00
Authentication code: 1152

Re: determining the pixel aspect ratio of a TIFF

Post by easyhtrees »

Is there a better image hosting site I can use? It's TIFF on disk, I don't know how it ended up being a PNG.
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: determining the pixel aspect ratio of a TIFF

Post by snibgo »

Don't use an image hosting website. They often convert the image to something else for display. Some allow the original to be downloaded, but some discard the original.

Instead, use a file hosting site. dropbox.com seems to work fine.

But you can do the test yourself:

Code: Select all

magick identify -verbose yourfile.tiff
Look for a line like "Resolution: 200x100"
snibgo's IM pages: im.snibgo.com
easyhtrees
Posts: 5
Joined: 2018-06-19T11:58:22-07:00
Authentication code: 1152

Re: determining the pixel aspect ratio of a TIFF

Post by easyhtrees »

I just tried that and sure enough, the AR is not 1. Thanks, I'll use this method for now.
User avatar
GeeMack
Posts: 718
Joined: 2015-12-01T22:09:46-07:00
Authentication code: 1151
Location: Central Illinois, USA

Re: determining the pixel aspect ratio of a TIFF

Post by GeeMack »

easyhtrees wrote: 2018-06-19T15:33:54-07:00I just tried that and sure enough, the AR is not 1. Thanks, I'll use this method for now.
This should give you both X and Y resolutions...

Code: Select all

magick input.tif -format "%[fx:resolution.x] %[fx:resolution.y]" info:
You can use those FX expressions in a calculation to get the aspect...

Code: Select all

magick input.tif -format "%[fx:resolution.x/resolution.y]" info:
If you're using IM6 use "convert" instead of "magick".
Post Reply