Script request/idea: Show correct thumbnail size.

Please check the FAQ (https://www.xyplorer.com/faq.php) before posting a question...
Post Reply
kunkel321
Posts: 645
Joined: 10 Jun 2012 03:45
Location: Near Seattle

Script request/idea: Show correct thumbnail size.

Post by kunkel321 »

An idea: A toolbar button, that switches the view to Thumbnails. Have the script look in the active folder, and find the first image file. Then apply a thumbnail size that is appropriate. for example if I'm viewing photos, a large Thumb size, but if it's 32x32 icons, then 32x32 Thumbs, and so on. Thoughts?
ste(phen|ve) kunkel

jupe
Posts: 2794
Joined: 20 Oct 2017 21:14
Location: Win10 22H2 120dpi

Re: Script request/idea: Show correct thumbnail size.

Post by jupe »

Here is a very bare bones version that I think is close to what you want, it only checks horizontal size, but you could easily add a check for vertical too, the button does nothing if no images found, but you could modify that as you see fit.

Code: Select all

	$file = quicksearch("/types={:Image} /l=1 /fn");
	if $file { 
		$size = property("System.Image.HorizontalSize", $file);
		if $size <= 64 {
			#306;
		} elseif $size < 200 {
			#307;
		} elseif $size >= 200 {
			#308;
		}
	}

kunkel321
Posts: 645
Joined: 10 Jun 2012 03:45
Location: Near Seattle

Re: Script request/idea: Show correct thumbnail size.

Post by kunkel321 »

Very cool! Thanks Jupe -- this does indeed work!

EDIT: A "multi-size thumbnail" image for the button.
Image
Heh.
ste(phen|ve) kunkel

jupe
Posts: 2794
Joined: 20 Oct 2017 21:14
Location: Win10 22H2 120dpi

Re: Script request/idea: Show correct thumbnail size.

Post by jupe »

After thinking about it some more, it might be better multiplying the dimensions instead of just checking the horizontal, something similar to this:

Code: Select all

   $file = quicksearch("/types={:Image} /l=1 /fn");
   if $file {
      $size = eval(replace(property("System.Image.Dimensions", $file), "x", "*"));
      if $size <= 4096 /*64*/ {
         #306;
      } elseif $size < 40000 /*200*/ {
         #307;
      } elseif $size >= 40000 {
         #308;
      }
   }
It is up to you...

kunkel321
Posts: 645
Joined: 10 Jun 2012 03:45
Location: Near Seattle

Re: Script request/idea: Show correct thumbnail size.

Post by kunkel321 »

Thanks for the alternate version, Jupe. For my own purpose, they seem to work the same. In case any noobs, like myself, see this post, I'll point out the the three default thumb sizes, as shown below, should roughly correspond to the sizes in the script.

Image
ste(phen|ve) kunkel

jupe
Posts: 2794
Joined: 20 Oct 2017 21:14
Location: Win10 22H2 120dpi

Re: Script request/idea: Show correct thumbnail size.

Post by jupe »

You wouldn't notice the difference between the scripts unless you were viewing images that were much smaller on 1 side than the other.
If desired you could read those config thumbnail setting sizes you have highlighted above within the script so that if you change them in config the script needn't be updated, it might add a minuscule delay though reading them each time, but here is it if you or anyone else is interested:

Code: Select all

	$file = quicksearch("/types={:Image} /l=1 /fn");
	if $file {
      $size = eval(replace(property("System.Image.Dimensions", $file), "x", "*"));
      if $size <= eval(getkey("Width", "Thumbs") . "*" . getkey("Height", "Thumbs")) {
         #306;
      } elseif $size <= eval(getkey("Width2", "Thumbs") . "*" . getkey("Height2", "Thumbs")) {
         #307;
      } else {
         #308;
      }
   }
For someone that changes thumbnail sizes semi-regularly it might be preferable, but the settings it would read are from the last save point so if you change thumbnail sizes in config, you would then need to save settings for the script to change its behavior.

highend
Posts: 13313
Joined: 06 Feb 2011 00:33
Location: Win Server 2022 @100%

Re: Script request/idea: Show correct thumbnail size.

Post by highend »

but the settings it would read are from the last save point
savesettings can write the current config to a (temp) ini file, so you can avoid that behavior...
One of my scripts helped you out? Please donate via Paypal

kunkel321
Posts: 645
Joined: 10 Jun 2012 03:45
Location: Near Seattle

Re: Script request/idea: Show correct thumbnail size.

Post by kunkel321 »

Clever! Thanks Highend!
ste(phen|ve) kunkel

jupe
Posts: 2794
Joined: 20 Oct 2017 21:14
Location: Win10 22H2 120dpi

Re: Script request/idea: Show correct thumbnail size.

Post by jupe »

highend wrote:savesettings can write the current config to a (temp) ini file, so you can avoid that behavior...
Personally I dislike creating temporary files and avoid that myself unless really necessary, if I was planning to use the above script for my own use I wouldn't want it to create a temporary file every time I changed to thumbnails view, another downside is that it wouldn't work when you are in Read Only mode, but yes it could appeal to some people to include that functionality, especially if using a RAM drive for the temp file and/or regularly changing thumbnail sizes, but a manual save if necessary would be my personal preference for this particular use case, otherwise last saved state would be acceptable.

Post Reply