Over in the Tips & Tricks area I had recently posted a short script to select image files in a folder that were a specific aspect ratio. That script applied to only one specific aspect ratio, 16x9. I tweaked the script to tighten up the code a bit and provided a menu to select different aspect ratio JPGs. You could assign it to a CTB or right click of an existing CTB. See screen shot.It can be helpful if you're like me and at times need to select files that are 16x9, 8x5, 4x3, or 3x2 aspect ratio from various camera photo or desktop wallpaper folders to move or copy JPG files to other computers with different screen aspect ratios. There are no existing filters for aspect ratio and there is no direct meta property for it. To obtain the actual aspect ratio you have to divide the image horizontal dimension (x) by it's vertical dimension (y). I know that aspect ratios of cameras and computer screens vary here and across the pond so if anyone would like to me to tweak the script for other aspect ratios, I'd be glad to do it.
Code: Select all
"Image Aspect Ratio to Select|:preview";
" 16x9 or 1.78";
sub _aspect;
" 8x5 or 1.60";
sub _aspect;
" 3x2 or 1.50";
sub _aspect;
" 4x3 or 1.33";
sub _aspect;
"_aspect";
$aspect_ratio = (gettoken(caller("caption"), -1, "or ", "t"));
selfilter "*.jpg", f; // select jpg files
End GetInfo("CountSelected") < 1, "There are no JPG files in this folder.";
$images_selected = get("selecteditemsnames", "|");
#251; // unselect all files
$orient = get("propertyindex", "Orientation"); //requires v12.60.0015, Orientation name varies across systems in German "Ausrichtung"
foreach($file, $images_selected, "|") {
$rotate = property("#$orient", $file); // image orientation
if (($rotate == "Rotate 90 degrees") || ($rotate == "Rotate 270 degrees")) {
$ratio = round((property("ImageY", $file)) / (property("ImageX", $file)), 2); }
else {
$ratio = round((property("ImageX", $file)) / (property("ImageY", $file)), 2); }
if ($ratio == $aspect_ratio) {
$selected = $file;
selectitems $selected, , ,"a"; }
}Note: the big black dot or bell beside the aspect ratios on the menu may not show as it does on the screen shot. The script is saved as an ANSI file and you can duplicate the bell by holding down the alt key and hitting 007 on the numpad. I loaded a folder full of images with all four of the aspect ratios to test and it appears to be working fine.
Edit on July 23, 2013: update to use new get("propertyindex", propertyname) in v12.60.0015 for more compatibility across systems, but you still may have to change the actual property e.g., "Rotate 90/270 degrees" line depending on language/translation.
For expanded compatibility on other systems/languages please see highend's version post #7.
Thanks,
Ken
XYplorer Beta Club