Main Menu

Aspect Ratio

Started by ArchZu, September 05, 2024, 05:37:35 AM

Previous topic - Next topic

ArchZu

Is there any norm or standard to classify the proportion. Searching I found places that show it as "2.40:1" and in other places it says "2.4:1", and when it is something like "2.00:1" some places leave it like "2:1".











I found this image showing the resolutions:


For now, I did this, but I don't know how to leave the value I named "Aspect Ratio Decimal Format":
exiftool -config aspect_ratio.config -ImageSize -AspectRatio -AspectRatioDecimalFormat -AspectRatioProportionFactor -Orientation 0/*
======== 0/3840x1574.jpg
Image Size                      : 3840x1574
Aspect Ratio                    : 1920:787
Aspect Ratio Decimal Format     : 2.43:1
Aspect Ratio Proportion Factor  : 2.4396
Orientation                     : Landscape
======== 0/3840x1600.jpg
Image Size                      : 3840x1600
Aspect Ratio                    : 12:5
Aspect Ratio Decimal Format     : 2.4:1
Aspect Ratio Proportion Factor  : 2.4000
Orientation                     : Landscape
======== 0/3840x1607.jpg
Image Size                      : 3840x1607
Aspect Ratio                    : 3840:1607
Aspect Ratio Decimal Format     : 2.38:1
Aspect Ratio Proportion Factor  : 2.3895
Orientation                     : Landscape
======== 0/3840x1620.jpg
Image Size                      : 3840x1620
Aspect Ratio                    : 64:27
Aspect Ratio Decimal Format     : 2.37:1
Aspect Ratio Proportion Factor  : 2.3704
Orientation                     : Landscape
======== 0/3840x1634.jpg
Image Size                      : 3840x1634
Aspect Ratio                    : 1920:817
Aspect Ratio Decimal Format     : 2.35:1
Aspect Ratio Proportion Factor  : 2.3501
Orientation                     : Landscape
======== 0/3840x1920.jpg
Image Size                      : 3840x1920
Aspect Ratio                    : 2:1
Aspect Ratio Decimal Format     : 2:1
Aspect Ratio Proportion Factor  : 2.0000
Orientation                     : Landscape
======== 0/3840x2021.jpg
Image Size                      : 3840x2021
Aspect Ratio                    : 3840:2021
Aspect Ratio Decimal Format     : 1.9:1
Aspect Ratio Proportion Factor  : 1.9000
Orientation                     : Landscape
======== 0/3840x2076.jpg
Image Size                      : 3840x2076
Aspect Ratio                    : 320:173
Aspect Ratio Decimal Format     : 1.84:1
Aspect Ratio Proportion Factor  : 1.8497
Orientation                     : Landscape
======== 0/3840x2160.jpg
Image Size                      : 3840x2160
Aspect Ratio                    : 16:9
Aspect Ratio Decimal Format     : 1.77:1
Aspect Ratio Proportion Factor  : 1.7778
Orientation                     : Landscape
======== 0/3840x2304.jpg
Image Size                      : 3840x2304
Aspect Ratio                    : 5:3
Aspect Ratio Decimal Format     : 1.66:1
Aspect Ratio Proportion Factor  : 1.6667
Orientation                     : Landscape
======== 0/3840x2880.jpg
Image Size                      : 3840x2880
Aspect Ratio                    : 4:3
Aspect Ratio Decimal Format     : 1.33:1
Aspect Ratio Proportion Factor  : 1.3333
Orientation                     : Landscape
   11 image files rea
Arch Linux (KDE Plasma)

StarGeek

Quote from: ArchZu on September 05, 2024, 05:37:35 AMIs there any norm or standard to classify the proportion. Searching I found places that show it as "2.40:1" and in other places it says "2.4:1", and when it is something like "2.00:1" some places leave it like "2:1".

Well, in both those cases, there's no difference. 2.40 is the same as 2.4. I would say it's just a style choice. I don't think you'll find anything that says it would have to be one or the other.

QuoteFor now, I did this, but I don't know how to leave the value I named "Aspect Ratio Decimal

I'm not sure what you're asking here.
* 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).

ArchZu

Quote from: StarGeek on September 05, 2024, 09:09:12 AMWell, in both those cases, there's no difference. 2.40 is the same as 2.4. I would say it's just a style choice. I don't think you'll find anything that says it would have to be one or the other.

Probably. I spent more time looking for this than writing the code. I thought someone had already come across this, as I saw some old posts talking about aspect ratio.
Previously on Exiftool (1)
Previously on Exiftool (2)


Quote from: StarGeek on September 05, 2024, 09:09:12 AMI'm not sure what you're asking here.
It was an example of the image above. To give you an idea of what I'm trying to do, but it's in descending order.
I don't know how to rename them, I didn't want to leave them all with the name "Aspect Ratio", so as not to get confused, the one at the bottom is in ascending order. Image

[Aspect Ratio] calculates the aspect ratio of given dimensions, simplifying it using the greatest common divisor (GCD).
[Aspect Ratio Decimal Format] Displays only with two decimal places, cutting the last two digits after the period in "Aspect Ratio Proportion Factor" and adding ":1" at the end. (I don't know if it uses rounding, but I'm not using it, just cutting the numbers)
[Aspect Ratio Proportion Factor] Divide the width by the height to 4 decimal places.
[Orientation] Determine orientation based on image appearance.

Image Size                      : 3840x2880
Aspect Ratio                    : 4:3
Aspect Ratio Decimal Format     : 1.33:1
Aspect Ratio Proportion Factor  : 1.3333
Orientation                     : Landscape
--------------------------------
Image Size                      : 3840x2304
Aspect Ratio                    : 5:3
Aspect Ratio Decimal Format     : 1.66:1
Aspect Ratio Proportion Factor  : 1.6667
Orientation                     : Landscape
--------------------------------
Image Size                      : 3840x2160
Aspect Ratio                    : 16:9
Aspect Ratio Decimal Format     : 1.77:1
Aspect Ratio Proportion Factor  : 1.7778
Orientation                     : Landscape
--------------------------------
Image Size                      : 3840x2076
Aspect Ratio                    : 320:173
Aspect Ratio Decimal Format     : 1.84:1
Aspect Ratio Proportion Factor  : 1.8497
Orientation                     : Landscape
--------------------------------
Image Size                      : 3840x2021
Aspect Ratio                    : 3840:2021
Aspect Ratio Decimal Format     : 1.90:1
Aspect Ratio Proportion Factor  : 1.9000
Orientation                     : Landscape
--------------------------------
Image Size                      : 3840x1920
Aspect Ratio                    : 2:1
Aspect Ratio Decimal Format     : 2.00:1
Aspect Ratio Proportion Factor  : 2.0000
Orientation                     : Landscape
--------------------------------
Image Size                      : 3840x1634
Aspect Ratio                    : 1920:817
Aspect Ratio Decimal Format     : 2.35:1
Aspect Ratio Proportion Factor  : 2.3501
Orientation                     : Landscape
--------------------------------
Image Size                      : 3840x1634
Aspect Ratio                    : 1920:817
Aspect Ratio Decimal Format     : 2.35:1
Aspect Ratio Proportion Factor  : 2.3501
Orientation                     : Landscape
--------------------------------
Image Size                      : 3840x1620
Aspect Ratio                    : 64:27
Aspect Ratio Decimal Format     : 2.37:1
Aspect Ratio Proportion Factor  : 2.3704
Orientation                     : Landscape
--------------------------------
Image Size                      : 3840x1607
Aspect Ratio                    : 3840:1607
Aspect Ratio Decimal Format     : 2.38:1
Aspect Ratio Proportion Factor  : 2.3895
Orientation                     : Landscape
--------------------------------
Image Size                      : 3840x1600
Aspect Ratio                    : 12:5
Aspect Ratio Decimal Format     : 2.40:1
Aspect Ratio Proportion Factor  : 2.4000
Orientation                     : Landscape
--------------------------------
Image Size                      : 3840x1574
Aspect Ratio                    : 1920:787
Aspect Ratio Decimal Format     : 2.43:1
Aspect Ratio Proportion Factor  : 2.4396
Orientation                     : Landscape
--------------------------------

I sent an email to a place that deals with this, I hope they respond, otherwise it will stay like this.
Arch Linux (KDE Plasma)

StarGeek

The only thing I would suggest is to not use Orientation as the name. It's already the name of the EXIF tag that is embedded by pretty much all cameras, and it would cause some confusion if you need to share the data.

@CWCorrea config file uses "Image Format". Maybe "Layout"? Going further back, Phil used simply HorV.

A tag name that is descriptive is a good thing, IMO, even if it is a bit long. You can always use a shortcut (see the example.config file) to create a short version. For example, instead of typing HierarchicalSubject all the time, I have a shortcut for it which is simply HS.
* 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).

ArchZu

It looked like this:

ffmpeg -y -f lavfi -i color=c=white:s=720x486:d=1 -aspect 4:3 -c:v libx264 -pix_fmt yuv420p -loglevel quiet /tmp/out.m4v && exiftool -config aspect_ratio.config -ImageSize -AR -ARDF -ARPF -LTO /tmp/out.m4v && rm /tmp/out.m4v
Image Size                      : 648x486
Aspect Ratio                    : 4:3
Aspect Ratio Decimal Format     : 1.33:1
Aspect Ratio Proportion Factor  : 1.333
Layout Orientation              : Landscape

ffmpeg -y -f lavfi -i color=c=white:s=720x486:d=1 -aspect 16:9 -c:v libx264 -pix_fmt yuv420p -loglevel quiet /tmp/out.m4v && exiftool -config aspect_ratio.config -ImageSize -AR -ARDF -ARPF -LTO /tmp/out.m4v && rm /tmp/out.m4v
Image Size                      : 864x486
Aspect Ratio                    : 16:9
Aspect Ratio Decimal Format     : 1.77:1
Aspect Ratio Proportion Factor  : 1.778
Layout Orientation              : Landscape

magick -size 1920x1440 xc:white jpg:- | exiftool -config aspect_ratio.config -ImageSize -AspectRatio -AspectRatioDecimalFormat -AspectRatioProportionFactor -LayoutOrientation -
Image Size                      : 1920x1440
Aspect Ratio                    : 4:3
Aspect Ratio Decimal Format     : 1.33:1
Aspect Ratio Proportion Factor  : 1.333
Layout Orientation              : Landscape

exiftool -config aspect_ratio.config -ImageSize -AR -ARDF -ARPF -LTO image.png
Image Size                      : 13500x9000
Aspect Ratio                    : 3:2
Aspect Ratio Decimal Format     : 1.50:1
Aspect Ratio Proportion Factor  : 1.500
Layout Orientation              : Landscape
Arch Linux (KDE Plasma)

Alan Clifford

Quote from: StarGeek on September 05, 2024, 09:09:12 AMWell, in both those cases, there's no difference. 2.40 is the same as 2.4. I would say it's just a style choice. I don't think you'll find anything that says it would have to be one or the other.

For some unknown and, perhaps, obscure reason, that made my pedant hackles rise  :)

When I were a lad, say 55 years ago, I was taught it was incorrect to have trailing zeros after the decimal point.

ArchZu

Quote from: Alan Clifford on September 06, 2024, 01:01:27 PMFor some unknown and, perhaps, obscure reason, that made my pedant hackles rise  :)

When I were a lad, say 55 years ago, I was taught it was incorrect to have trailing zeros after the decimal point.

To the left, before the decimal point. Do you know if it can have zeros?

magick -size 100x200 xc:white jpg:- | exiftool -config aspect_ratio.config -ImageSize -AR -ARDF -ARPF -LTO -
Image Size                      : 100x200
Aspect Ratio                    : 1:2
Aspect Ratio Decimal Format     : 0.5:1
Aspect Ratio Proportion Factor  : 0.500
Layout Orientation              : Portrait
Arch Linux (KDE Plasma)

StarGeek

Quote from: ArchZu on September 06, 2024, 01:55:51 PMTo the left, before the decimal point. Do you know if it can have zeros?

Yes, sprintf should be able to do this. But I can never keep the rules straight with it. ChatGPT should be good with this, or try searching StackExchange or PerlMonks.
* 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).

ArchZu

#8
I made some changes, I used "Math::BigFloat;" to manipulate the values with precision. See if I did something wrong, or if there is something that can be improved. Maybe some argument that could have a more correct name.

Without the "Math::BigFloat;", large value inaccurat:
magick -size 2480x3508 xc:white jpg:- | exiftool -config -ARPF -UserParam ARPFL=53 -
Aspect Ratio Proportion Factor  : 0.7069555302166476984382370574166998267173767089843750
With "Math::BigFloat;", precise value.
magick -size 2480x3508 xc:white jpg:- | exiftool -config -ARPF -UserParam ARPFL=53 -
Aspect Ratio Proportion Factor  : 0.70695553021664766248574686431014823261117445838084378

Current:
exiftool -config aspect_ratio.config -ImageSize -ARS -ARDF -ARPF -LTO -EAR -TP -UserParam ARPFL=10 9.png
Image Size                      : 2480x3508
Aspect Ratio Storage            : 620:877
Aspect Ratio Decimal Format     : 0.71:1
Aspect Ratio Proportion Factor  : 0.7069555302
Layout Orientation              : Portrait
Estimated Aspect Ratio          : 45:62
Total Pixels                    : 8699840

exiftool -config aspect_ratio.config -imagesize -AspectRatioStorage
-AspectRatioDecimalFormat -AspectRatioProportionFactor -LayoutOrientation -EstimatedAspectRatio -TotalPixels -UserParam RatioLength=53 9.png
Image Size                      : 2480x3508
Aspect Ratio Storage            : 620:877
Aspect Ratio Decimal Format     : 0.71:1
Aspect Ratio Proportion Factor  : 0.70695553021664766248574686431014823261117445838084378
Layout Orientation              : Portrait
Estimated Aspect Ratio          : 45:62
Total Pixels                    : 8699840


AspectRatioStorage, the AspectRatioStorage calculation, only returns absolute numbers, without decimal places.

AspectRatioDecimalFormat, returns values with two decimal places, the maximum allowed is two decimal places. If there is a zero "1.60:1" before ":", the zero will be removed "1.6:1". If there are two zeros "2.00:1" they will be removed "2:1". The values "1.777" are rounded to "1.78:1" last rounds the last penultimate, in this case the last penultimate "7" was rounded to "8".

AspectRatioProportionFactor, returns the division of "AspectRatioStorage", with decimal places, the last digit is not rounded, for example "1.77777" remains as "1.777". The size can be set between "3" and "512" using "-UserParam RatioLength=3" or "-UserParam ARPFL=5", if a value above "512" is entered in "-UserParam" it is set to "3".

LayoutOrientation, Determines the screen orientation using the width and height of the image "Square", "Landscape", "Portrait".

EstimatedAspectRatio, estimates the closest Aspect Ratio of the image based on the list inside "my %standard_ratios = ()", using "AspectRatioProportionFactor". Returns the equal or closest value of the video within "my %standard_ratios = ()". If within "my %standard_ratios = ()" there are only three values "4:3", "7:3", "16:9", it will only speculate between these 3 values the closest, it will not display the exact one. If there is an exact value that returns the same "AspectRatioProportionFactor" within "my %standard_ratios = ()", it will display the exact value. If there are two or more exact values that return the same "AspectRatioProportionFactor", they will be displayed separated by a comma followed by a space "1.5:1, 3:2". Is displaying all values at "https://en.wikipedia.org/wiki/Display_resolution_standard", "https://en.wikipedia.org/wiki/Aspect_ratio_(image)" date copied [2024/09/07].

ValueEquationAspectRatio, Returns the value of "AspectRatioProportionFactor" with 1024 digits, the last digit is rounded, This is only for testing don't use. Use "AspectRatioProportionFactor".

TotalPixels, calculates the total number of pixels in the image, multiplying the width by the height.
Arch Linux (KDE Plasma)