This aspect ratio column makes no attempt to calculate fraction ratios from decimals.
I really think this is not a need for that. This column determines whether common aspect ratios match the keyword aspect ratio to 2 decimals using a regular expression.
Different image sources often report decimal aspect ratios that differ very small from true fractions. If more decimals are needed, the code can be easily changed.
The aspect ratios that match are displayed as 4:3, 3:4,16:9, 9:16, 3:2, 2:3, 5:4, 4:5 or to 2 decimals. Other aspect ratios can be easily added to the code.
<?xml version="1.0"?>
<evalcolumn align="0" attrrefresh="no" autorefresh="yes" customgrouping="no" foldertype="all" header="Aspect" keyword="Aspect" maxstars="5" namerefresh="yes" reversesort="no" title="Aspect:Ratio" type="0">x=aspectratio;
ratio = RegEx(x, "(.*)(\..{2})", "\1\2");
output(x);
if ( ratio == RegEx(4 as double / 3 as double , "(.*)(\..{2})", "\1\2") )
{
ratio = "4:3";
}
elseif ( ratio == RegEx(3 as double / 4 as double , "(.*)(\..{2})", "\1\2") )
{
ratio = "3:4";
}
elseif ( ratio == RegEx(16 as double / 9 as double , "(.*)(\..{2})", "\1\2") )
{
ratio = "16:9";
}
elseif ( ratio == RegEx(9 as double / 16 as double , "(.*)(\..{2})", "\1\2") )
{
ratio = "9:16";
}
elseif ( ratio == RegEx(3 as double / 2 as double , "(.*)(\..{2})", "\1\2") )
{
ratio = "3:2";
}
elseif ( ratio == RegEx(2 as double / 3 as double , "(.*)(\..{2})", "\1\2") )
{
ratio = "2:3";
}
elseif ( ratio == RegEx(5 as double / 4 as double , "(.*)(\..{2})", "\1\2") )
{
ratio = "5:4";
}
elseif ( ratio == RegEx(4 as double / 5 as double , "(.*)(\..{2})", "\1\2") )
{
ratio = "4:5";
}
else
{
ratio = aspectratio_text;
}
return ratio;</evalcolumn>
They are all the same except I made a perfect 16:9 pic and check out the responses (orange underline). Any numbers *except a normal human readable aspect ratio, such as 16:9.
I used an aspect ratio calculator and my custom sizes do result in two decimal places. So two decimal places does seem to be the right way of displaying it (just a note).
I added the factory aspect ratio column and it changed it's mind about the numbers. And the aspect ratio group up and decided to tell us it's a 16:9 (this is another eval column for a different header title).
Why does 'Landscape' always say 'other' ? Is there two kinds of landscape?
All this trouble cause GPSoft doesn't want to give us an header title alias field in the appearance settings.
You can just copy and paste this.
Clicking the small clipboard icon in the upper right corner of the code box copies the code to your clipboard. Then go to Preferences / File Display Columns / Evaluator Columns and click the paste button. It is the far right menu button. The column will then appear in the list.
I'm not sure why that doesn't work for you.
I use Textpad as my code editor, but I don't have Dopus configured to use an external editor.
I wrote this using the default Evaluator Column editor.
I copied to clipboard by right clicking on the preferences column listing and choosing Share To Clipboard.
Pressing the Preferences paste menu button translates the XML to a new Evaluator Column listing for me.
But, if it helps, here it is without the XML
x=aspectratio;
ratio = RegEx(x, "(.*)(\..{2})", "\1\2");
output(x);
if ( ratio == RegEx(4 as double / 3 as double , "(.*)(\..{2})", "\1\2") )
{
ratio = "4:3";
}
elseif ( ratio == RegEx(3 as double / 4 as double , "(.*)(\..{2})", "\1\2") )
{
ratio = "3:4";
}
elseif ( ratio == RegEx(16 as double / 9 as double , "(.*)(\..{2})", "\1\2") )
{
ratio = "16:9";
}
elseif ( ratio == RegEx(9 as double / 16 as double , "(.*)(\..{2})", "\1\2") )
{
ratio = "9:16";
}
elseif ( ratio == RegEx(3 as double / 2 as double , "(.*)(\..{2})", "\1\2") )
{
ratio = "3:2";
}
elseif ( ratio == RegEx(2 as double / 3 as double , "(.*)(\..{2})", "\1\2") )
{
ratio = "2:3";
}
elseif ( ratio == RegEx(5 as double / 4 as double , "(.*)(\..{2})", "\1\2") )
{
ratio = "5:4";
}
elseif ( ratio == RegEx(4 as double / 5 as double , "(.*)(\..{2})", "\1\2") )
{
ratio = "4:5";
}
else
{
ratio = aspectratio_text;
}
return ratio;
Oh damn.
I thought this was a copy paste into the existing evaluator code box method, just like the method for buttons. Because I didn't know there was a dedicated paste button for this. That would explain my other evaluator too.
How would I modify the 'aspect ratio group' data to make it only show "Landscape" or "Portrait" ?
I can try: if "Landscape (other)" then "Landscape". etc. But some of the fields are populating the numbers too, which looks pretty random. ?
I wonder if testing the aspect ratio and a result of more than 1 = "Landscape". Less than 1 = "Portrait" (Unless I have the ratio backwards). ?
This "aspect ratio group" seems to be telling the user what format type of form factor the image is. I think the only options for this are landscape, portrait or square. I'm unaware of any others.
I'm assuming by how it populates the field there isn't any metadata embedded that says this, so it's just looking at the aspect ratio to determine this "group". So I'm wanting to see what it is by quickly looking at this column. I want to get rid of the "(other)", and the added numbers. Only those three words would be possible. There might be more advanced reasons for having (other) etc. exist, but is too advanced for my use case. And ya, I changed the header from "aspect ratio group" to "orientation".
@ASUNDER
I made one for you, but I'm reluctant to post it here.
I had to go through customs ( @Leo ) to post this under Buttons/Scripts .
Posting the revision you are looking for does seem to defeat the purpose of @Leo screening it.
So I sent you a private message with what I think you are looking for.