Show (nearest) Aspect Ratio
-
Stef123
Show (nearest) Aspect Ratio
Any way to do this? As a pop-up or mouse-hover info to see it on thumbs as well. Or via custom columns or any other technique.
Purpose = quickly spot photos that do NOT match usual print sizes. I know there are 3rd party tool out there, but I am wondering if this were possible with on-board equipment?
Purpose = quickly spot photos that do NOT match usual print sizes. I know there are 3rd party tool out there, but I am wondering if this were possible with on-board equipment?
-
klownboy
- Posts: 4459
- Joined: 28 Feb 2012 19:27
- Location: Windows 11, 25H2 Build 26200.8037 at 100% 2560x1440
Re: Show (nearest) Aspect Ratio
Hey Stef123,
I have a PhotoCropper script in which one menu item provides a photo's aspect ratio if it's one of the standard aspect ratios (e.g., 16:9, 8:5, 4:3, 3:2) and if it is not will will popup a window giving the photo's dimensions and tell you it's not a common aspect ratio. My original Photo Cropper script is here http://www.xyplorer.com/xyfc/viewtopic. ... =photocrop but does not have this capability. After more testing, I've been meaning to upload a much expanded and hopefully improved version to the site, but other things took priority like the ThumbnailMaintenance script. This one menu item, I suppose could be adapted using something like TheQwerty's great ItemUnderMouse AHK/XY script http://www.xyplorer.com/xyfc/viewtopic. ... se#p113307 which would provide this information by hitting a key combination while the mouse is hovering over a thumbnail. The main part of the PhotoCropper script obviously is to crop the photo to the aspect ratio desired. It would be some additional amount of work to modify it to show the nearest common ratio.
Ken
I have a PhotoCropper script in which one menu item provides a photo's aspect ratio if it's one of the standard aspect ratios (e.g., 16:9, 8:5, 4:3, 3:2) and if it is not will will popup a window giving the photo's dimensions and tell you it's not a common aspect ratio. My original Photo Cropper script is here http://www.xyplorer.com/xyfc/viewtopic. ... =photocrop but does not have this capability. After more testing, I've been meaning to upload a much expanded and hopefully improved version to the site, but other things took priority like the ThumbnailMaintenance script. This one menu item, I suppose could be adapted using something like TheQwerty's great ItemUnderMouse AHK/XY script http://www.xyplorer.com/xyfc/viewtopic. ... se#p113307 which would provide this information by hitting a key combination while the mouse is hovering over a thumbnail. The main part of the PhotoCropper script obviously is to crop the photo to the aspect ratio desired. It would be some additional amount of work to modify it to show the nearest common ratio.
Ken
To see the attached files, you need to log into the forum.
-
Stef123
Re: Show (nearest) Aspect Ratio
Thanks Ken,
your script tells me I cannot crop whatever.jpg because it is not an image
The instructions say s.th. about overwriting certain lines but there was not really a download package to overwrite, just a copy and paste operation, so I figured it might have been changed already ... anyway, the cropping part is not really important, I got tools for that.
I also have tools that show a complete file list with all ratios and their nearest preset, but I thought it couldn't hurt to ask if it might have been implemented in XY. Maybe I ought to try setting up a custom column to get hands-on experience with that.
your script tells me I cannot crop whatever.jpg because it is not an image
The instructions say s.th. about overwriting certain lines but there was not really a download package to overwrite, just a copy and paste operation, so I figured it might have been changed already ... anyway, the cropping part is not really important, I got tools for that.
I also have tools that show a complete file list with all ratios and their nearest preset, but I thought it couldn't hurt to ask if it might have been implemented in XY. Maybe I ought to try setting up a custom column to get hands-on experience with that.
-
klownboy
- Posts: 4459
- Joined: 28 Feb 2012 19:27
- Location: Windows 11, 25H2 Build 26200.8037 at 100% 2560x1440
Re: Show (nearest) Aspect Ratio
Hi Stef123,
Sorry, I didn't intend for you to try that old script. It's 2 1/2 years old and though it still works for me (I just DL'ed it and ran it), it relies on property index of #11 to determine if the file is an image file. So if you are using some other OS or language, it's probably not going to return the correct result. My newer script should solve that by using a property index based on the OS/language. To actually perform the cropping that script also requires that you have "Irfanview" installed. With the new one, you have a choice of using Irfanview or Image Magick.
On that note, even on my new version I should evaluate using the new system properties like property "System.Kind" to determine if the file is a "picture".
Anyway, as far as your request, I think that would be possible to obtain the aspect ratio of the image, convert it to decimal form, compare it against all the "common" aspect ratios also converted to decimal form, and determine which is the closest. From there I suppose rather than having a message box state that it's not a common aspect ratio (as it the above capture), it could actually state which common aspect ratio it is closest. I'm looking at that now.
Sorry, I didn't intend for you to try that old script. It's 2 1/2 years old and though it still works for me (I just DL'ed it and ran it), it relies on property index of #11 to determine if the file is an image file. So if you are using some other OS or language, it's probably not going to return the correct result. My newer script should solve that by using a property index based on the OS/language. To actually perform the cropping that script also requires that you have "Irfanview" installed. With the new one, you have a choice of using Irfanview or Image Magick.
On that note, even on my new version I should evaluate using the new system properties like property "System.Kind" to determine if the file is a "picture".
Anyway, as far as your request, I think that would be possible to obtain the aspect ratio of the image, convert it to decimal form, compare it against all the "common" aspect ratios also converted to decimal form, and determine which is the closest. From there I suppose rather than having a message box state that it's not a common aspect ratio (as it the above capture), it could actually state which common aspect ratio it is closest. I'm looking at that now.
-
Stef123
Re: Show (nearest) Aspect Ratio
Ha, you're right, Ken
it does work on my notebook, but not on systems with another locale. I won't need it often anyway - or I would have brought it up much sooner. Last Sunday s.o. asked me how to get rid of borders on photo prints. So I pulled out my keychain with the USB stick and ran my tools. That's when it occured to me it were nice to see this info at one glance in XY columns, to sort by aspect ratio and spot the buggy ones right away.
Definitely not something you'd expect in a general purpose file manager, so I guess it probably makes more sense to ask the developers of dedicated tools to improve their interface, rather than re-creating the whole thing in XY.
it does work on my notebook, but not on systems with another locale. I won't need it often anyway - or I would have brought it up much sooner. Last Sunday s.o. asked me how to get rid of borders on photo prints. So I pulled out my keychain with the USB stick and ran my tools. That's when it occured to me it were nice to see this info at one glance in XY columns, to sort by aspect ratio and spot the buggy ones right away.
Definitely not something you'd expect in a general purpose file manager, so I guess it probably makes more sense to ask the developers of dedicated tools to improve their interface, rather than re-creating the whole thing in XY.
-
admin
- Site Admin
- Posts: 66302
- Joined: 22 May 2004 16:48
- Location: Win8.1, Win10, Win11, all @100%
- Contact:
Re: Show (nearest) Aspect Ratio
I hope everybody here knows that XY has full support for showing aspect ratio or searching for it.
You can have patterns like this in search and color filters:
You can have an aspect ratio column like this (or through the Custom Column GUI):
Quoting the change log:
You can show the aspect ratio property like this:
You can have patterns like this in search and color filters:
Code: Select all
prop:#AspectRatio: 16:9Code: Select all
setcolumns("Name,:s-image.dimensions,:s-image.datetaken,:s-aspectratio");Code: Select all
v13.80.0105 - 2014-03-06 19:54
+ Customize Columns: The column headers right-click menu got a new command
"Select Special Property...". Here you can select one of XYplorer's
special properties from a list. The column caption is automatically set if
you leave it unnamed in the Configure Custom Column dialog.
The following special properties (also known from the <prop> variable) are
currently supported:
Bit Depth (#audio.bitdepth)
Bit Rate (#audio.bitrate)
Channels (#audio.channels)
Sample Rate (#audio.samplerate)
Aspect Ratio (#aspectratio)
Hard Links (#hardlinks)
MD5 (#hash.md5)
SHA1 (#hash.sha1)
SHA256 (#hash.sha256)
SHA512 (#hash.sha512)
CRC32 (#hash.crc32)
Junction Target (#junctiontarget)
Shortcut Target (#shortcuttarget)
Code: Select all
text <prop #aspectratio>;FAQ | XY News RSS | XY X
-
Stef123
Re: Show (nearest) Aspect Ratio
Whoa - nice, very nice.

I am glad we had this talk
This will not just suffice my original request, it spawns new ideas what I might do with it.
I am glad we had this talk
This will not just suffice my original request, it spawns new ideas what I might do with it.
-
klownboy
- Posts: 4459
- Joined: 28 Feb 2012 19:27
- Location: Windows 11, 25H2 Build 26200.8037 at 100% 2560x1440
Re: Show (nearest) Aspect Ratio
Thanks Don for passing on the custom column information. I have some of my misc folders with photos set up to provide the aspect ratio in a custom column.
Question: I see in the help that the newly "discovered" system property commands are locale independent. I'm updating a photo cropping script and I'd like to make it as OS and language independent as possible. It has to determine a number of things about a file before it does its work like for one, is it a "picture". So to avoid having to do determine the property index for "kind" in a few languages (kind|art|tipo) and then use that index with property to see if it matches the translations for (Picture|Bild|Imagen|Image|Imagine), am I right in stating I can use property('System.Kind') and the result in any language, like German will be "picture" if the file is a picture?
By the way, Ste123 was trying to determine what aspect ratio a picture was closest to if the if/when it's not a "common" picture. I think I can do that in a script.
Thanks,
Ken
Question: I see in the help that the newly "discovered" system property commands are locale independent. I'm updating a photo cropping script and I'd like to make it as OS and language independent as possible. It has to determine a number of things about a file before it does its work like for one, is it a "picture". So to avoid having to do determine the property index for "kind" in a few languages (kind|art|tipo) and then use that index with property to see if it matches the translations for (Picture|Bild|Imagen|Image|Imagine), am I right in stating I can use property('System.Kind') and the result in any language, like German will be "picture" if the file is a picture?
By the way, Ste123 was trying to determine what aspect ratio a picture was closest to if the if/when it's not a "common" picture. I think I can do that in a script.
Thanks,
Ken
-
admin
- Site Admin
- Posts: 66302
- Joined: 22 May 2004 16:48
- Location: Win8.1, Win10, Win11, all @100%
- Contact:
Re: Show (nearest) Aspect Ratio
Yes, it's "picture" also in German Windows. 
FAQ | XY News RSS | XY X
-
klownboy
- Posts: 4459
- Joined: 28 Feb 2012 19:27
- Location: Windows 11, 25H2 Build 26200.8037 at 100% 2560x1440
Re: Show (nearest) Aspect Ratio
Thanks Don, that's what I was hoping. These system properties will help in making scripts more language/OS independent especially since the property index can be different from one language to the next.
-
admin
- Site Admin
- Posts: 66302
- Joined: 22 May 2004 16:48
- Location: Win8.1, Win10, Win11, all @100%
- Contact:
Re: Show (nearest) Aspect Ratio
These system properties are a great discovery! I was wondering for years why something like this doesn't exist. Suddenly it's there. Not sure if it's new or just was never documented by MS.
FAQ | XY News RSS | XY X
-
Stef123
Re: Show (nearest) Aspect Ratio
Mouth-watering. There are times when I don't encounter it all, but on occasion I hit a whole batch of faulty rations. Not sure how they come about. Mainly edited photos that people had souped up with fancy frames that they don't want on the prints, or they shaved off transparent edges with Photoshop's trim feature.klownboy wrote: trying to determine what aspect ratio a picture was closest to if the if/when it's not a "common" picture. I think I can do that in a script.
-
admin
- Site Admin
- Posts: 66302
- Joined: 22 May 2004 16:48
- Location: Win8.1, Win10, Win11, all @100%
- Contact:
Re: Show (nearest) Aspect Ratio
Note that XY already does this closest-ratio smartness to some extent.Stef123 wrote:klownboy wrote: trying to determine what aspect ratio a picture was closest to if the if/when it's not a "common" picture. I think I can do that in a script.
FAQ | XY News RSS | XY X
-
klownboy
- Posts: 4459
- Joined: 28 Feb 2012 19:27
- Location: Windows 11, 25H2 Build 26200.8037 at 100% 2560x1440
Re: Show (nearest) Aspect Ratio
I think what you mean is you have built some tolerance in the dimensions of the image file in determining if the image is is a 16x9, 8x5 or 4x3. In Stef123 case, he talking about odd ball images that are well outside those tolerances for the "common" photo aspect ratios. I made a script (almost done) which will obtain the aspect ratio of the image, convert it to decimal form, compare it against all the "common" aspect ratios (also converted to decimal form), and determine which is the closest. So with that information, he could crop the photo a standard (e.g.,16x9) if desired.admin wrote:Note that XY already does this closest-ratio smartness to some extent.
-
admin
- Site Admin
- Posts: 66302
- Joined: 22 May 2004 16:48
- Location: Win8.1, Win10, Win11, all @100%
- Contact:
XYplorer Beta Club