Create folder.jpg from random images

Discuss and share scripts and script files...
Post Reply
serendipity
Posts: 3360
Joined: 07 May 2007 18:14
Location: NJ/NY

Create folder.jpg from random images

Post by serendipity »

After Don included the feature "folder thumbnails" i wanted to create a folder.jpg by picking random images from the current folder. That way i could see a snapshot of images contained in that folder without going into it.
I used irfanview to create a panorama of 12 images (4 columns X 3 rows). So this is only for people using irfanview.
But I have included a link to it's portable version below for those who want to try it. its 1.15mb.

So here's the script:

Code: Select all

//folderJPG.xys
//This script creates folder.jpg for the current folder by picking 12 random images and making a panorama of 4 columns X 3 rows (using irfanview image viewer)
//If the current folder has subfolders then folder.jpg will be a result of iamges from those folders too
//If the current folder (including subfolders) has less than 12 images then 4 random mages are picked and making 2 columns X 2 rows
//You can opt to sample images regularly instead of randomly

// DEPENDENCIES: IrfanView (this script will work as is, if XYplorer and IrfanView are in the same folder and the script is placed inside XYplorer's script folder). 

  filter "folder.jpg"; 
  $folderexists= getinfo ("countitems"); 
  IF ($folderexists > 0) { 
  selfilter "folder.jpg"; 
  focus; 
//duplicate folder.jpg (basically backing up old folder.jpg)
  #165;
  filter; 
  } 
  ELSE { 
  filter;
  }
    
//set views to details 
 #302;
//Search current folder for jpg, tif, jpeg, png, gif but exclude folder.jpg and its backups.
//If you want folder.jpg for only the current folder and not its subfolders then remove r after / from the end of next line

  goto "?: !folder*.jpg & \*.jpg | \*.tif | \*.jpeg | \*.png | \*.gif /r";
//count items in list
 $items=getinfo("countitems");
 //sortby random order
 #331;
//if you want regularly sampled images instead of random images then remove the // from next line 
//  sortby name;
 
 IF ($items>=12) {

//Select first list item
 sel 1;
 $file1=<curitem>;
//select 9th list item if 100 items
 sel ($items/11);
 $file2=<curitem>;
//select 18th list item if 100 items
 sel (($items/11)*2);
 $file3=<curitem>;
 //select 27th list item if 100 items
 sel (($items/11)*3);
 $file4=<curitem>;
 //select 36th list item if 100 items
 sel (($items/11)*4);
 $file5=<curitem>;
 //select 45th list item if 100 items
 sel (($items/11)*5);
 $file6=<curitem>;
 //select 54th list item if 100 items
 sel (($items/11)*6);
 $file7=<curitem>;
 //select 63rd list item if 100 items
 sel (($items/11)*7);
 $file8=<curitem>;
 //select 72nd list item if 100 items
 sel (($items/11)*8);
 $file9=<curitem>;
 //select 81st list item if 100 items
 sel (($items/11)*9);
 $file10=<curitem>;
 //select 90th list item if 100 items
 sel (($items/11)*10);
 $file11=<curitem>;
 //Select last list item
 sel $items;
 $file12=<curitem>;
 
   
 $pan1="<curpath>\pan1.jpg";
 $pan2="<curpath>\pan2.jpg";
 $pan3="<curpath>\pan3.jpg";
 $pan4="<curpath>\pan4.jpg";
 $pan5="<curpath>\pan5.jpg";
 $pan6="<curpath>\pan6.jpg";
 $pan7="<curpath>\pan7.jpg";
 $pan8="<curpath>\pan8.jpg";
 $pan9="<curpath>\pan9.jpg";
 $pan10="<curpath>\pan10.jpg";
 $pan11="<curpath>\pan11.jpg";
 $pan12="<curpath>\pan12.jpg";
 
 run """..\IrfanView\i_view32.exe"" $file1 /resize=(300 ,300) /aspectratio /resample /convert $pan1 /killmesoftly",,1;
 run """..\IrfanView\i_view32.exe"" $file2 /resize=(300 ,300) /aspectratio /resample /convert $pan2 /killmesoftly",,1;
 run """..\IrfanView\i_view32.exe"" $file3 /resize=(300 ,300) /aspectratio /resample /convert $pan3 /killmesoftly",,1;
 run """..\IrfanView\i_view32.exe"" $file4 /resize=(300 ,300) /aspectratio /resample /convert $pan4 /killmesoftly",,1;
 run """..\IrfanView\i_view32.exe"" $file5 /resize=(300 ,300) /aspectratio /resample /convert $pan5 /killmesoftly",,1;
 run """..\IrfanView\i_view32.exe"" $file6 /resize=(300 ,300) /aspectratio /resample /convert $pan6 /killmesoftly",,1;
 run """..\IrfanView\i_view32.exe"" $file7 /resize=(300 ,300) /aspectratio /resample /convert $pan7 /killmesoftly",,1;
 run """..\IrfanView\i_view32.exe"" $file8 /resize=(300 ,300) /aspectratio /resample /convert $pan8 /killmesoftly",,1;
 run """..\IrfanView\i_view32.exe"" $file9 /resize=(300 ,300) /aspectratio /resample /convert $pan9 /killmesoftly",,1;
 run """..\IrfanView\i_view32.exe"" $file10 /resize=(300 ,300) /aspectratio /resample /convert $pan10 /killmesoftly",,1;
 run """..\IrfanView\i_view32.exe"" $file11 /resize=(300 ,300) /aspectratio /resample /convert $pan11 /killmesoftly",,1;
 run """..\IrfanView\i_view32.exe"" $file12 /resize=(300 ,300) /aspectratio /resample /convert $pan12 /killmesoftly",,1;
 
 
 
 $panorama1="<curpath>\panorama1.jpg";
 $panorama2="<curpath>\panorama2.jpg";
 $panorama3="<curpath>\panorama3.jpg";
 
 run """..\IrfanView\i_view32.exe"" /panorama=(1,$pan1,$pan2,$pan3,$pan4) /convert $panorama1 /silent",,1;
 run """..\IrfanView\i_view32.exe"" /panorama=(1,$pan5,$pan6,$pan7,$pan8) /convert $panorama2 /silent",,1;
 run """..\IrfanView\i_view32.exe"" /panorama=(1,$pan9,$pan10,$pan11,$pan12) /convert $panorama3 /silent",,1;
 
 run """..\IrfanView\i_view32.exe"" /panorama=(2,$panorama1,$panorama2,$panorama3) /convert ""<curpath>\folder.jpg"" /silent",,1;
 
 delete 0,0, $pan1|$pan2|$pan3|$pan4|$pan5|$pan6|$pan7|$pan8|$pan9|$pan10|$pan11|$pan12|$panorama1|$panorama2|$panorama3;
 //go to previous location
 #520; 
 goto <curpath>;
 }
 
 ELSEIF ($items>6 && $items <12){
 //Select first list item
 sel 1;
 $file1=<curitem>;
//select 33rd list item if 100 items
 sel ($items/3);
 $file2=<curitem>;
//select 66th list item if 100 items
 sel (($items/3)*2);
 $file3=<curitem>;
 //select last list
 sel $items;
 $file4=<curitem>;
 
   
 $pan1="<curpath>\pan1.jpg";
 $pan2="<curpath>\pan2.jpg";
 $pan3="<curpath>\pan3.jpg";
 $pan4="<curpath>\pan4.jpg";
 
 run """..\IrfanView\i_view32.exe"" $file1 /resize=(600 ,600) /aspectratio /resample /convert $pan1 /killmesoftly",,1;
 run """..\IrfanView\i_view32.exe"" $file2 /resize=(600 ,600) /aspectratio /resample /convert $pan2 /killmesoftly",,1;
 run """..\IrfanView\i_view32.exe"" $file3 /resize=(600 ,600) /aspectratio /resample /convert $pan3 /killmesoftly",,1;
 run """..\IrfanView\i_view32.exe"" $file4 /resize=(600 ,600) /aspectratio /resample /convert $pan4 /killmesoftly",,1;
 
 $panorama1="<curpath>\panorama1.jpg";
 $panorama2="<curpath>\panorama2.jpg";
 
 run """..\IrfanView\i_view32.exe"" /panorama=(1,$pan1,$pan2) /convert $panorama1 /silent",,1;
 run """..\IrfanView\i_view32.exe"" /panorama=(1,$pan3,$pan4) /convert $panorama2 /silent",,1;
 
 
 run """..\IrfanView\i_view32.exe"" /panorama=(2,$panorama1,$panorama2) /convert ""<curpath>\folder.jpg"" /silent",,1;
 
 delete 0,0, $pan1|$pan2|$pan3|$pan4|$panorama1|$panorama2;
 //go to previous location
 #520; 
 goto <curpath>; 
 }
 
 ELSE { 
 goto <curpath>;
 } 
  

Direct link to IrfanView zip file.
Download

The above script will work without modifications if you extract the zip contents into a folder called "IrfanView" which is in the same folder as XYplorer, for eg: C:\Program files.

Have fun and Please report problems too.

kiwichick
Posts: 648
Joined: 08 Aug 2012 04:14
Location: Windows 10 Pro 22H2, 150% scaling

Re: Create folder.jpg from random images

Post by kiwichick »

Thank you serendipity, OMG am I glad I came across this??? Much fun to be had!!! It rocks :appl: I made a couple of changes:

1. Creates a 5 column x 3 row image.

2. 'set views to details' would toggle to Thumbnails if the view was already Details. So I changed it so it stays on Details:

Code: Select all

//set views to details
   $view = get("view");
   if ($view == 0){ }
   else {
   #302;
   }
3 I also got rid of the 'less than 12' section at the end and just put and end command at the beginning:

Code: Select all

end(getinfo ("countitems") <16), "There needs to be at least 16 image files in the folder";
Now it rocks even more for me!!!
Windows 10 Pro 22H2

serendipity
Posts: 3360
Joined: 07 May 2007 18:14
Location: NJ/NY

Re: Create folder.jpg from random images

Post by serendipity »

kiwichick wrote: Now it rocks even more for me!!!
Glad that it still works after 3 years. Feel free to make changes and share your script here.

kiwichick
Posts: 648
Joined: 08 Aug 2012 04:14
Location: Windows 10 Pro 22H2, 150% scaling

Re: Create folder.jpg from random images

Post by kiwichick »

Thanks serendipity, Yes, I was wondering if would still work after so much time. And, being new to scripting, if it didn't work I was worried I wouldn't have a clue what bits to change in order to fix it so I was VERY pleased that it did :biggrin:
Windows 10 Pro 22H2

Post Reply