GIF pixel aspect ratio

Started by eeeps, September 01, 2020, 04:20:04 PM

Previous topic - Next topic

eeeps

I came across a GIF today with non-square pixels, a thing I didn't know was possible. But sure enough, "Pixel Aspect Ratio" is defined on page 10 of https://www.w3.org/Graphics/GIF/spec-gif89a.txt

Here's the GIF: https://res.cloudinary.com/eran2903/image/upload/v1598980749/testing/out_yojkh6.gif

In VLC it displays "correctly" at 2272 (W) x 1280 (H). The pixels, however, are not square; they're 3.155...:1

In browsers the GIF displays incorrectly, at 720 (W) x 1280 (H), which would be the display resolution if the pixels were square... but they're not.

EXIFTool, as far as I can tell, only reports the pixel-data-count, and does not provide a way to see the pixel aspect ratio or display dimensions.

Am I missing something? If not, consider this a feature request!


StarGeek

Just to let you know, this will require Phil's attention and he's away until the end of the week.
* Did you read FAQ #3 and use the command listed there?
* Please use the Code button for exiftool code/output.
 
* Please include your OS, Exiftool version, and type of file you're processing (MP4, JPG, etc).

eeeps

No worries and thanks for the heads up!

Phil Harvey

Thanks.  I'll look into extracting this information with the next ExifTool release.

- Phil
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux/PowerShell, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

blue-j

Just checking in on this - was this ever done?  I see "gif:aspectratio" but that would be a confusing moniker for PAR.  - J

Phil Harvey

Yes, this was done in version 12.06 (released on Sept 11).  It is called AspectRatio because ExifTool converts from Pixel Aspect Ratio according to the formula given in your reference:

            viii) Pixel Aspect Ratio - Factor used to compute an approximation
            of the aspect ratio of the pixel in the original image.  If the
            value of the field is not 0, this approximation of the aspect ratio
            is computed based on the formula:

            Aspect Ratio = (Pixel Aspect Ratio + 15) / 64


- Phil
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux/PowerShell, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

blue-j

This is very odd to me.  Of course your choices are as impeccable as always, but if you solve this equation for the GIF provided, the PAR appears absurd.  That is, if Aspect Ratio = 3.15625, and Aspect Ratio (3.15625) = (Pixel Aspect Ratio + 15) / 64, doesn't that make PAR = 187?

Adobe gets plenty of things wrong, that's for sure!  But they treat that value as the PAR itself, it seems to me, and with good visual results; please see attachments.

Please forgive me, I am probably being foolish yet again...  : p

- J


blue-j

As an interesting aside, Adobe never writes to aspectratio, even if you have non-square pixels.  It will read it and apply PAR correction as shown in my prior screenshots, but it doesn't seem to ever write it.  - J

Phil Harvey

Yes, the raw value stored in the file is 187 for this tag.  I admit that the names used in the specification could be better, and so maybe I should have taken the opportunity to use different names in ExifTool.  Would you be happier if the tag was named PixelAspectRatio?

- Phil
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux/PowerShell, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

blue-j

I read and reread the spec a few times.  It's quite opaque to me!  But yes, I think we should correct their nomenclature.  In no world is "187" a pixel aspect ratio.  But 3.15625 is!  Thanks, Phil!  - J

blue-j

I suppose if one were a purist, you could have two fields.  aspectratio, which is the raw 187 (also doesn't make sense to me), and pixelaspectratio, which is the computed 3.15625?

Phil Harvey

I think I'll just change it to PixelAspectRatio since that seems to make the most sense (ignoring the specification).

- Phil
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux/PowerShell, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).