ThumbnailViewerGallery

Discuss and share scripts and script files...
klownboy
Posts: 4397
Joined: 28 Feb 2012 19:27
Location: Windows 11, 25H2 Build 26200.7171 at 100% 2560x1440

ThumbnailViewerGallery

Post by klownboy »

The script title pretty much says it all. I got the itch to do this because of the request in this thread here. It's a simple script which will allow you to set up folders of your choosing to view the image thumbnails in a Gallery mode. By Gallery, I mean the thumbnail view where you'll have: no padding (no gaps), Plain Style (no border), no Captions, and "Zoom to Fill" is ON (see the picture below). Well, you say I can do that already. Yes, you can, but you can't have both styles. Zoom to fill, padding, captions, no border options are across the board. This script will allow the user to set up some image folders for thumbnail viewing settings totally different from his normal setting. For example, my normal thumbnail configuration is with thumbnail Padding set to "1", Captions are ON, and I have "Zoom to Fill" option OFF. This script allows me to view thumbnails for the same (or different) image folders in the Gallery mode (i.e., no gap, no border, Zoom to Fill ON.). Out of the box this is not possible in XYplorer since the "Zoom to Fill" style thumbnails require a different cache. A folder's thumbnail cache is based on the folder thumbnail size and whether the "Zoom to Fill" option is ON or OFF.
Thumbnail Normal mode (left) vs Gallery mode (right).JPG
Thumbnail Normal mode (left) vs Gallery mode (right).JPG (127.55 KiB) Viewed 5787 times
Basically the script relies on a new modified version of the XYplorer.ini file, I've called XYplorer_Gallery.ini and a separate thumbnail cache folder "GalleryThumbs". This way we're not tampering with the "normal" XY thumbnail folder. A second instance of XY is started using the XYplorer_Gallery.ini file and XY will make new caches in the GalleryThumbs folder. You may want to give some thought as to which image folders you'll want to see in the gallery mode obviously since new caches are made for the image folders. As is the case normally, when you first enter the folder it will take time to generate the new thumbs and of course that depends on the amount and quality of the images and the type and size of thumbnails. The cache is generated behind the scenes do give it for the 2nd instance to display. Another benefit of using this method is that you can if you'd like have totally different size thumbnails specified than what you have in the "Normal" comfiguration (XYplorer.ini). You can have this new instance of XY come up in a larger size or even maximized or adjust other settings like background color. These types of adjustments you can do on your own by modifying XYplorer_Gallery.ini or by making adjustments in the Configuration while in the second instance (you'll see the name of the ini file being modified at the top of the Configuration dialog box - to be sure the proper ini file is being changed).

It will take a few minutes to set it up, but once done, you'll be able to view your thumbnails in a gallery mode with no padding, caption or borders. If you have your normal thumbnail configuration is already set that way, you could have just the opposite arrangement (i.e., have the new thumbnail viewing mode display thumbnails with captions and gaps and borders. The point is it gives you the flexibility to have it both ways. If you'd like, you could also modify other viewing or arrangement features in the new mode like have completely different thumbnail sizes, no navigation panel, no tabs bar, no toolbar, and even the backgroung color.

1.) Start by going into the menu File | Settings Special | "Save Copy of Configuration As..." to save your current XYplorer.ini configuration as XYplorer_Gallery.ini.
2.) Now load the new ini file by going into the File | Settings Special menu again and this time use the Load Configuration menu to load your new ini file, XYplorer_Gallery.ini.
3.) Once the new ini file is loaded, go to Tools | Configuration | Thumbnails and change settings to your hearts content, to the new or different features you'd like for you gallery mode. Note: the header for the Config dialog should display XYplorer_Gallery.ini. For example I checked off, "Zoom to Fill", since I normally don't have it ON. I also changed the Padding to "0", Style to "Plain" and unchecked Show Captions. Most importantly while in that config screen, go to "Cache thumbnails on disk" and make sure it is checked and use the "..." box to enter a new thumbnails cache folder called GalleryThumbs. With the XYplorer folder selected, select make New folder (or you can make the new folder first within XYplorer). I made made my new folder directly off the XYplorer folder. You on the other hand, may have a XY data folder in that case you could make it off the XYdata folder. In any case, you can make it at the same level as the normal "Thumbnails" folder.
4.) Once done, save all your setting changes. They'll be saved to "XYplorer_Gallery.ini".
5.) Now go back to the File | Settings Special | Load Configuration... and load your original ini file, XYplorer.ini.
6.) Now we're ready to modify the posted script to your system (save as UTF-8 with BOM).
a.) I've added some notes to the script where you have to use your own picture folder. You'll want to replace what I have for variable $DIR_PICS ("H:\Pictures") with an parent image folder which has multiple subfolders of images such as "G:\Wallpaper" or "D:\Photos".
b.) Change the icon referred to as variable $ICO_PICS if you like to one of your choosing. I referred to a generic XY built-in one. You could use something like "<xyicons>\k321-icon-219.ico".
c.) You can also add individual separate folders that you would like to view in gallery mode as an example in line #9 of script. Save your script changes.
d.) Lastly, create a user button, CTB or user command to invoke the script or try it out first by hi-lighting the script and select Load selected script file from the scripting menu.
e.) When you run the script a list of the image folders should be displayed, pick one and the thumbs will be displayed in gallery mode (no padding (no gaps), Plain Style (no border), no Captions, and "Zoom to Fill" is ON) or however you established your settings in XYplorer_Gallery.ini. Important though, with the first run on any particular folder, XY will take time to generate the thumbnails before you actually see the new 2nd instance of XY display. On subsequent runs on a folder previously viewed, the thumbnail display should be very quick as it normally is.
f.) Click on the corner X to exit the 2nd instance of XY. I also have a customized keyboard shortcut set for the ` key to exit a second instance of XY with this one liner, if(get("instance") == "2") {exit n}.

Code: Select all

"Main";
 //*** Change your version to use a parent folder in which you have subfolders of images like "G:\Wallpaper\1920x1080"
 //*** where you have many subfolders of images like Canada, Ireland, Brazil under it.
   $DIR_PICS = "H:\Pictures";
 //*** Change the icon referenced here to one of your choosing like "<xyicons>\k321-icon-219.ico"
   $ICO_PICS = :viewthumbs;     
 //*** You can add specific individual folder(s) here if you like in the same manner as I've added the "Kindle" folder below.
		$AllPicFolders = listfolder("$DIR_PICS", "*", "2", "|") . "|" . "G:\PDFs and Books\Kindle\";
	$menu= ""; unset $MenuCaller;
		foreach ($PicFolder, $AllPicFolders, "|") {
			if !(listfolder($PicFolder, "*", 2 + 32) >= "1") {
				$PicFolderBase = getpathcomponent($PicFolder, "base"); 
				$menu = $menu . "   ●   $PicFolderBase" perm $MenuCaller = "$PicFolder" . ";" . "<crlf>";
			}
		}
	$PICMENU = """   PHOTO FOLDER THUMBS|$ICO_PICS""" . ";" . "-" . "<crlf>" . "$menu";
 
      load($PICMENU, , s);
      if (isset($MenuCaller) == "1") {
 // *** It makes sense to maximize the pane if you're only viewing thumbs (e.g., turn the nav panel off, etc). If you have saved layouts use that instead.
			run """<xy>"" /ini=XYplorer_Gallery.ini ""$MenuCaller"" /script=""::if get(#663){#663};if get(#662){#662};if get(#661){#661};if get(#1061){#1061};if get(#665){#665};if get(#800){#800;}"""; }
		else {end (1);}

"_Terminate";
   unset $MenuCaller;
Sorry for the lengthy discussion above, but I wanted to make sure everything was properly covered. Don't let in scare you. It will only take a few minutes to set it up.
Good luck and please let me know if you have any problems.
Ken

ksarnelli
Posts: 154
Joined: 13 Dec 2014 04:48

Re: ThumbnailViewerGallery

Post by ksarnelli »

Great work klownboy, and thanks so much for this! I used your instructions and script and tweaked it a little for my specific needs. I basically turned it into a UDC that executes the 'run' line of your script and passes it the current folder, rather than popping up a menu.

Code: Select all

run """<xy>"" /ini=XYplorer_Gallery.ini /script=""::goto '<curpath>';if get(#663){#663};if get(#662){#662};if get(#661){#661};if get(#1061){#1061};if get(#665){#665};if get(#800){#800};#308;filter '{:Image}|{:Video}';""";
I also added the #308 command to force the largest thumbnail view and added a filter so it only shows images and videos.

I do have a few questions though that maybe you or someone else can help me with:

1 - As you can see I'm using a goto instead of just passing <curpath> as part of the command line to XY. I did this because paper folders passed via the command line weren't working (the curpath being appended to XY's app path), however they work fine with the goto command. Is it possible to pass paper folder paths to XY via the normal command line?

2 - Is there a way to pass the entire address bar as a parameter instead of just the current path? For example, when using branch view <curpath> does not include the "? /:flat" portion of the address bar.

3 - Even with padding set to 0 I am still getting a tiny amount of padding (several pixels) between the thumbnails. In your screenshot you have absolutely no padding and that's what I'd like to see as well. Any idea where to check for this?

Thanks again!

ksarnelli
Posts: 154
Joined: 13 Dec 2014 04:48

Re: ThumbnailViewerGallery

Post by ksarnelli »

ksarnelli wrote:
3 - Even with padding set to 0 I am still getting a tiny amount of padding (several pixels) between the thumbnails. In your screenshot you have absolutely no padding and that's what I'd like to see as well. Any idea where to check for this?
I discovered that by setting [Thumbs]->Padding to -2 directly in the .ini that the padding is completely removed. Is this normal? Shouldn't 0 do that?

admin
Site Admin
Posts: 64843
Joined: 22 May 2004 16:48
Location: Win8.1, Win10, Win11, all @100%
Contact:

Re: ThumbnailViewerGallery

Post by admin »

That was before 16.20. Get the latest version...

klownboy
Posts: 4397
Joined: 28 Feb 2012 19:27
Location: Windows 11, 25H2 Build 26200.7171 at 100% 2560x1440

Re: ThumbnailViewerGallery

Post by klownboy »

ksarnelli wrote:I discovered that by setting [Thumbs]->Padding to -2 directly in the .ini that the padding is completely removed. Is this normal? Shouldn't 0 do that?
Hi ksarnelli, are you using the latest beta? I ask because Don corrected an issue that I brought up with the padding. I had to do the exact same thing to get rid of the gap (set it to -2 in the ini file), but with the change, I no longer have to do that. See this thread here http://www.xyplorer.com/xyfc/viewtopic. ... =0#p133674 Oh I see Don just piped in to answer. I'll take a look at your other questions tomorrow.

That's the idea though, you can set up the new ini file however you like. I luse loadlayout in the run statement and also have a different overall size of the XY display as well as other differences. I wanted to keep it simple as far as what I posted.

By the way, you can have completely different thumbnail sizes than what is specified in you normal XYplorer.ini. Just go into Configuration while that new XYplorer_Gallery.ini is in use and change the sizes to your liking. You really shouldn't have to call out the thumbnail view size (CID #308), it should remember it after the first time. That's why I didn't bother. You could even specify a 320x320 size thumbnail even though your largest size might be 240x240 in the normal XYplorer.ini.
Last edited by klownboy on 19 Jan 2016 23:01, edited 1 time in total.

ksarnelli
Posts: 154
Joined: 13 Dec 2014 04:48

Re: ThumbnailViewerGallery

Post by ksarnelli »

klownboy wrote:
ksarnelli wrote:I discovered that by setting [Thumbs]->Padding to -2 directly in the .ini that the padding is completely removed. Is this normal? Shouldn't 0 do that?
Hi ksarnelli, are you using the latest beta? I ask because Don corrected an issue that I brought up with the padding. I had to do the exact same thing to get rid of the gap (set it to -2 in the ini file), but with the change, I no longer have to do that. See this thread here http://www.xyplorer.com/xyfc/viewtopic. ... =0#p133674 Oh I see Don just piped in to answer. I'll take a look at your other questions tomorrow.

That's the idea though, you can set up the new ini file however you like. I luse loadlayout in the run statement and also have a different overall size of the XY display as well as other differences. I wanted to keep it simple as far as what I posted.
Thanks Don and klownboy. I should have tried that first.

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

Re: ThumbnailViewerGallery

Post by highend »

2 - tab("get", "term") and a goto as /script=...
One of my scripts helped you out? Please donate via Paypal

ksarnelli
Posts: 154
Joined: 13 Dec 2014 04:48

Re: ThumbnailViewerGallery

Post by ksarnelli »

highend wrote:2 - tab("get", "term") and a goto as /script=...
Works like a charm, thanks!

klownboy
Posts: 4397
Joined: 28 Feb 2012 19:27
Location: Windows 11, 25H2 Build 26200.7171 at 100% 2560x1440

Re: ThumbnailViewerGallery

Post by klownboy »

Hi ksarnelli, thanks for the comments. That's a nice use of the script, simply to run the gallery mode on the current folder. Based on that I may set up my pull down menu as a right click on a CTB and the left click have as an on-demand set-up on the current folder as you did. Though I think I'll have to be careful not to be invoking it too much or the cache will end up the size of my normal thumbnail cache - nearly 1.5 gig. Thankfully drive space is cheap nowadays.

Concerning the use of CID #308 (largest size thumbnails): You may want to check the view mode first to see if the list panel is already in that thumbnail mode because if not, using #308 will toggle the mode. So I'd go with: if(Get('View') != '6') {#308} This way, if you happen to be in large thumbnail mode when using normal XYplorer configuration, the view will stay the same view mode when you go into gallery mode. It would be a good way of simply switching form normal thumbs to gallery thumbs.

I may look back at my ThumbnailMaintenance script to see if I have to change something to invoke it on a different cache when using a different ini file.

I see highend answered your second question. Thanks highend.

I'm not sure about your first question concerning paper and the command line. I'll have to do some experimenting...it may be that the format would have to be changed from (for example): D:\Tools\XYplorer\Paper\Wallpaper\Ireland.txt to paper:Wallpaper\Ireland

klownboy
Posts: 4397
Joined: 28 Feb 2012 19:27
Location: Windows 11, 25H2 Build 26200.7171 at 100% 2560x1440

Re: ThumbnailViewerGallery

Post by klownboy »

Hi again ksarnelli, as far as loading a paper folder, I see what you mean about the folder being appended to the XY folder. Try using <curpath> up front instead of in the script section:

Code: Select all

run """<xy>"" ""<curpath>"" /ini=XYplorer_Gallery.ini /script=""::if get(#663){#663};if get(#662){#662};if get(#661){#661};if get(#1061){#1061};if get(#665){#665};if get(#800){#800};if(Get('View') != '6'){#308};filter '{:Image}|{:Video}';""";
It seems to work fine for me if I'm in a paper folder or normal folder. It was working earlier, but for some reason not now...even when placing the ""<curpath>"" after the "ini=..." as the last switch. According to the HELP command line switches, it should override whatever is in the ini and be used as the startup path. It may be a bug since "paper:Wallpaper\Ireland" is treated as a folder as far as the thumbnail cache is concerned. If you look at the contents of the thumbnail cache dat2 file you'll see that syntax.

I mentioned earlier that I have a User Command set for the "`" key to exit a 2nd instance of XY if in a 2nd instance. Well, I modified that user command under the User menu...User | Manage Commands. Under the "Run script" category have a new Run script set-up as: Caption "Exit 2nd instance of XY or run Gallery Mode" and the Script as:

Code: Select all

  if(get("instance") == "2") {exit n;}
    elseif(get("instance") == "1") {run """<xy>"" ""<curpath>"" /ini=XYplorer_Gallery.ini /script=""::if get(#663){#663};if get(#662){#662};if get(#661){#661};if get(#1061){#1061};if get(#665){#665};if get(#800){#800};if(Get('View') != '6'){#308};filter '{:Image}|{:Video}';""";} 
With this defined key, the script will switch to the gallery mode if in the normal XY and exit the gallery mode if your already in it. So essentially it's toggling the gallery mode. :tup:

Edit: All the layout information is in XYplorer_Gallery.ini under the [Layout] section so once the layout is established, technically you don't need to specify any layout code unless you for some reason change the gallery layout (e.g., display the main menu or tab bar) while in XY using XYplorer_Gallery.ini. This example also hides the titlebar for the gallery view mode using a small AHK script...it's on the forum here.

Code: Select all

run """<xy>"" /ini=XYplorer_Gallery.ini ""<curpath>"" /script=""::loadlayout('thumbs');if(Get('View') != '6'){#308};open 'D:\Tools\AutoHotkey\AHKscripts\TB_XY_hide.ahk';"""; }

ksarnelli
Posts: 154
Joined: 13 Dec 2014 04:48

Re: ThumbnailViewerGallery

Post by ksarnelli »

Hi klownboy - thanks for the tip showing how to check the current view mode before setting it.

I wasn't able to get paper folders working consistently from the command line, and that was without even trying to include the non-path portion of the address bar. I wound up with:

Code: Select all

$curpath = replace(tab('get', 'term'), "'", "''");
 run """<xy>"" /ini=XYplorer_Gallery.ini /script=""::goto '$curpath';if get(#663){#663};if get(#662){#662};if get(#661){#661};if get(#1061){#1061};if get(#665){#665};if get(#800){#800};if(Get('View') != '6'){#308};filter '{:Image}|{:Video}';""";
It works well, but there is that initial shutter when it navigates from the default startup path to the $curpath. It would be great if XY supported passing an entire address bar as a command line param.

I'm pretty new to XY scripting so I may not be doing things properly (I actually have a gigantic programming background though! ha). As you can see I'm using a generic replace function to escape the single quotes for use in the scripting portion of the command line. I saw an XY quote() function but it only seems to support double quotes. What's the ideal way to escape a string for use in the command above?

I like your way of toggling the virtual gallery mode using a single user command. That would work great for me since I am already using a user command to enter gallery mode.

Thanks!

klownboy
Posts: 4397
Joined: 28 Feb 2012 19:27
Location: Windows 11, 25H2 Build 26200.7171 at 100% 2560x1440

Re: ThumbnailViewerGallery

Post by klownboy »

Hi ksarnelli, I totally agree it would be nice to have paper folders work from the command line. I asked the question last night here. As you said, you can definitely tell the difference when you have to use SC goto.

Until then it might be better to use the command line when you can for non-paper folders and use the scripting "goto" only for paperfolders.

Code: Select all

  if(get("instance") == "2") {exit n; end(1);}
  elseif(get("instance") == "1") {
        $curpath = replace(tab('get', 'term'), "'", "''");
      if (gettoken($curpath, 1, ':') != 'paper') {
          run """<xy>"" /script=""::if get(#663){#663};if get(#662){#662};if get(#661){#661};if get(#1061){#1061};if get(#665){#665};if get(#800){#800};if(Get('View') != '6'){#308};filter '{:Image}|{:Video}';"" /ini=XYplorer_Gallery.ini ""$curpath"""; }
      else {
          run """<xy>"" /ini=XYplorer_Gallery.ini /script=""::goto '$curpath';if get(#663){#663};if get(#662){#662};if get(#661){#661};if get(#1061){#1061};if get(#665){#665};if get(#800){#800};if(Get('View') != '6'){#308};filter '{:Image}|{:Video}';""";}
   }
I stayed with your $curpath variable for the post, but I haven't had any issues using XY variable <curpath> even for paper folders used with the SC goto. Yes, I'm really liking the toggle feature for the Gallery View. Thanks.

ksarnelli
Posts: 154
Joined: 13 Dec 2014 04:48

Re: ThumbnailViewerGallery

Post by ksarnelli »

klownboy wrote:Hi ksarnelli, I totally agree it would be nice to have paper folders work from the command line. I asked the question last night here. As you said, you can definitely tell the difference when you have to use SC goto.

Until then it might be better to use the command line when you can for non-paper folders and use the scripting "goto" only for paperfolders.

Code: Select all

  if(get("instance") == "2") {exit n; end(1);}
  elseif(get("instance") == "1") {
        $curpath = replace(tab('get', 'term'), "'", "''");
      if (gettoken($curpath, 1, ':') != 'paper') {
          run """<xy>"" /script=""::if get(#663){#663};if get(#662){#662};if get(#661){#661};if get(#1061){#1061};if get(#665){#665};if get(#800){#800};if(Get('View') != '6'){#308};filter '{:Image}|{:Video}';"" /ini=XYplorer_Gallery.ini ""$curpath"""; }
      else {
          run """<xy>"" /ini=XYplorer_Gallery.ini /script=""::goto '$curpath';if get(#663){#663};if get(#662){#662};if get(#661){#661};if get(#1061){#1061};if get(#665){#665};if get(#800){#800};if(Get('View') != '6'){#308};filter '{:Image}|{:Video}';""";}
   }
I stayed with your $curpath variable for the post, but I haven't had any issues using XY variable <curpath> even for paper folders used with the SC goto. Yes, I'm really liking the toggle feature for the Gallery View. Thanks.
Hi klownboy - the $curpath in the previous example includes the entire address bar (ie. if you were using branch view it would also pass along the "? /:flat" portion of the address bar and not just the <curpath>). I wonder if Don's paper folder fix would make this work as well.

klownboy
Posts: 4397
Joined: 28 Feb 2012 19:27
Location: Windows 11, 25H2 Build 26200.7171 at 100% 2560x1440

Re: ThumbnailViewerGallery

Post by klownboy »

I think that Don's fix will probably only recognize the paper folder written with the syntax "paper:Wallpaper" as a folder on the command line as he did a while back with SC "exists". Honestly I haven't been using branch view so I don't know much about it. If it doesn't work on branch view at least we'll be a big step further as far what folders are working command line does work. Did you notice that Don is going to make the fix? Maybe you should mention branch view on that thread. So an example of the branch view as seen in the AB would be something like this: F:\MP3? /:flat ...and that's what is returned by: $curpath = replace(tab('get', 'term'), "'", "''");
Edit: I asked Don about flat view in the other thread.

klownboy
Posts: 4397
Joined: 28 Feb 2012 19:27
Location: Windows 11, 25H2 Build 26200.7171 at 100% 2560x1440

Re: ThumbnailViewerGallery

Post by klownboy »

Hi ksarnelli, with Don's beta v16.20.0005 paperfolders are working great from command line. He said if he didn't get the /flat on that beta the next beta will. It does appear to be working in 16.20.0005.

Post Reply