Windows thumbnails for folders?
Posted: 24 Nov 2021 18:03
When the folder has 2 or more images,show more thumbnails?but a new option must be added...
Forum for XYplorer Users and Developers
https://www.xyplorer.com/xyfc/
Code: Select all
"_Initialize";
global $cur_folder, $montage_exe, $irfanview_exe;
$montage_exe = "D:\Graphics\ImageMagick\montage.exe";
$irfanview_exe = "D:\Graphics\IrfanView64\i_view64.exe";
// Montage.exe is part of the ImageMagick package (free) which can be obtained at http://www.imagemagick.org/script/binary-releases.php#windows
// Look for "portable" Windows binary packages (zip) on left side. You can download the no install package where no registry entries are made
// IrfanView is also free to use https://www.irfanview.com
// Change the paths above to reflect your montage.exe and/or IrfanView location.
if(exists(<curitem>) == 2) {$cur_folder = <curitem>;} else {$cur_folder = <curpath>;}
if(substr($cur_folder, -1) != "\") {$cur_folder = $cur_folder . "\";}
" ● Zoomed View Folder Montage [random images current folder]|:viewthumbs";
global $cur_folder, $folder_name, $view, $cur_view, $geometry, $tile, $montage_exe;
goto $cur_folder;
sub "_ViewData";
sub "_Montage";
run """$montage_exe"" @filelist.txt -geometry $geometry-1-1 -auto-orient -tile $tile $folder_name folder.jpg", , 2,0;
delete 0, 0, $cur_folder . "filelist.txt";
delete 0, 0, $cur_folder . "p_i_c_*";
#1001;
sub "_ViewPic";
// attrstamp("h", 1, $cur_folder . "folder.jpg"); //if you'd rather not hide the folder montage comment out this line
sub "_Finish_it"; end 1;
" ● Polaroid View Folder Montage [random images current folder]|:viewthumbs";
global $cur_folder, $folder_name, $view, $cur_view, $geometry, $tile, $montage_exe;
goto $cur_folder;
sub "_ViewData";
sub "_Montage";
run """$montage_exe"" @filelist.txt -geometry $geometry-1-1 -auto-orient +polaroid -background grey70 -tile $tile -font Tahoma -pointsize 26 -title $folder_name folder.jpg", , 2,0;
delete 0, 0, $cur_folder . "filelist.txt";
delete 0, 0, $cur_folder . "p_i_c_*";
#1001;
sub "_ViewPic";
// attrstamp("h", 1, $cur_folder . "folder.jpg"); //if you'd rather not hide the folder montage comment out this line
sub "_Finish_it"; end 1;
" ● Folder Montage [random images current folder and subs]|:refresh";
global $cur_folder, $view, $cur_view, $geometry, $tile, $thumbsize_X, $thumbsize_Y, $montage_exe, $paths;
if(strlen($cur_folder) < 4) {$root_warning = 1;}
if($root_warning == "1") {end confirm("You are in the root directory. Are you sure you want to create folder thumbnails for the entire drive?") == 0, "Good choice, bye!";}
sub "_ViewData";
$paths = $cur_folder . <crlf> . (folderreport("dirs", "r", $cur_folder, "r", , <crlf>));
foreach ($ea_path, $paths, <crlf>, "e") {
if (substr($ea_path, -1) != "\") {
$ea_path = $ea_path . "\";
}
goto $ea_path; // experienced issues using a path with filelist.txt within the montage cmd line, so moving into each folder
if(exists($ea_path . "folder.jpg")) {
attrstamp("h", 4, $ea_path . "folder.jpg");
delete 0, 0, $ea_path . "folder.jpg";
}
$image_list = formatlist(folderreport("files", "r", "$ea_path", , , <crlf>), "f", <crlf>, "*.jpeg<crlf>*.jpg<crlf>*.bmp<crlf>*.png<crlf>*.mp4<crlf>*.mov<crlf>*.wmv<crlf>*.avi");
$i = gettoken($image_list, "count", <crlf>);
if ($i >= "4") {$count = 4; $geometry = "720x720"; $tile = "2x2";}
elseif ($i < "4") {
$continue = confirm("This folder [$ea_path] does not contain enough image files to make a proper folder montage.<crlf 2>" . quote("Yes") . " to contnue with script [since other sub folders may contain images], or<crlf 2>" . quote("No") . " to exit script now.", <crlf>,1,4);
if($continue=="1"){continue;}
elseif($continue=="0"){end 1;}
}
$random_images = GetToken(formatlist($image_list, 'x', <crlf>), $count, <crlf>,, 1); //randomize the no of images "$count" in $image_list
$i = 1;
$final_images = "";
foreach($image, $random_images, <crlf>, "e") {
savethumb($image, "p_i_c_$i.jpg", $thumbsize_X,, "jpg100", "5", 2); //border of "5"
// savethumb($image, "p_i_c_$i.jpg", $thumbsize_X,, "jpg100", , 2); //no border
$final_images .= "p_i_c_$i.jpg" . <crlf>;
$i++;
}
$final_images = trim(regexreplace($final_images, "^(.*\\)(.*?$)", "'$2'"),<crlf>, "r");
writefile("filelist.txt", $final_images);
$folder_name = quote(getpathcomponent($ea_path, "component", -1));
run """$montage_exe"" @filelist.txt -geometry $geometry-1-1 -auto-orient -tile $tile $folder_name folder.jpg", , 2,0;
delete 0, 0, $ea_path . "filelist.txt";
delete 0, 0, $ea_path . "p_i_c_*";
sub "_ViewPic";
attrstamp("h", 1, $ea_path . "folder.jpg"); //if you'd rather not hide the folder montage comment out this line
}
sub "_Finish_it";
"-"
" ● Zoomed View Montage IrfanView [random images current folder]|:viewthumbs";
global $cur_folder, $irfanview_exe;
goto $cur_folder;
sub "_ViewData";
sub "_Montage";
$pic1 = $cur_folder . "p_i_c_1.jpg";
$pic2 = $cur_folder . "p_i_c_2.jpg";
$pic3 = $cur_folder . "p_i_c_3.jpg";
$pic4 = $cur_folder . "p_i_c_4.jpg";
$panorama1 = $cur_folder . "panorama1.jpg";
$panorama2 = $cur_folder . "panorama2.jpg";
$panorama_complete = $cur_folder . "folder.jpg";
run """$irfanview_exe"" /jpgq=100 /panorama=(1,$pic1,$pic2) /convert $panorama1 /silent",,2,0;
run """$irfanview_exe"" /jpgq=100 /panorama=(1,$pic3,$pic4) /convert $panorama2 /silent",,2,0;
run """$irfanview_exe"" /jpgq=100 /panorama=(2,$panorama1,$panorama2) /convert $panorama_complete /silent",,2,0;
delete 0, 0, "$pic1|$pic2|$pic3|$pic4|$panorama1|$panorama2";
#1001;
sub "_ViewPic";
// attrstamp("h", 1, $cur_folder . "folder.jpg"); //if you'd rather not hide the folder montage comment out this line
sub "_Finish_it"; end 1;
"_Montage";
global $cur_folder, $folder_name, $cur_view, $view, $geometry, $tile, $thumbsize_X, $thumbsize_Y;
if("|1|4|5|6|8|9|" UnLikeI "*|$view|*") {
msg "Present view [$cur_view] is not a thumbnail or tile viewing mode."; end 1; // You should have a FVS/tab setting in thumbnail mode
}
if(exists($cur_folder . "folder.jpg")) {
attrstamp("h", 4, $cur_folder . "folder.jpg");
delete 0, 0, $cur_folder . "folder*.jpg";
}
$image_list = formatlist(folderreport("files", "r", $cur_folder, , , <crlf>), "f", <crlf>, "*.jpeg<crlf>*.jpg<crlf>*.bmp<crlf>*.png<crlf>*.mp4<crlf>*.mov<crlf>*.wmv<crlf>*.avi");
$i = gettoken($image_list, "count", <crlf>);
if ($i >= "4") {
$count = 4; $geometry = "720x720"; $tile = "2x2";}
elseif ($i < "4") {
msg "This Folder [$cur_folder] does not contain enough image files to make a proper folder montage.";end 1;}
$random_images = GetToken(formatlist($image_list, 'x', <crlf>), $count, <crlf>,, 1); //randomize the no of images "$count" in $image_list
$i = 1;
$final_images = "";
foreach($image, $random_images, <crlf>, "e") {
if (substr(gettoken(caller("caption"), 2, "●", "t"),2, 8) LikeI "Polaroid") {
savethumb($image, "p_i_c_$i.jpg", $thumbsize_X,, "jpg100",, 2);}
elseif (substr(gettoken(caller("caption"), 1, "[", "t"), -9,) LikeI "IrfanView") {
savethumb($image, "p_i_c_$i.jpg", $thumbsize_X,, "jpg100","2" , 2);} //for Irfanview adjust border value "2" in this case to suit
else {
savethumb($image, "p_i_c_$i.jpg", $thumbsize_X,, "jpg100","4" , 2);} //for IM adjust border value "4" in this case to suit
$final_images .= "p_i_c_$i.jpg" . <crlf>;
$i++;
}
$final_images = trim(regexreplace($final_images, "^(.*\\)(.*?$)", "'$2'"),<crlf>, "r");
if !(substr(gettoken(caller("caption"), 1, "[", "t"), -9,) LikeI "IrfanView") {
writefile($cur_folder . "filelist.txt", $final_images);
}
$folder_name = quote(getpathcomponent($cur_folder, "component", -1));
"_ViewData";
global $view, $cur_view, $thumbsize_X, $thumbsize_Y, $thumbsize, $multiple;
if !(substr(gettoken(caller("caption"), 1, "[", "t"), -9,) LikeI "IrfanView") {
$multiple = "6";} //multiplication factor of thumbnail size you can change this if you like even make it "2"
else {
$multiple = "3";}
$T_sm = getkey("Width", "Thumbs") . "x" . getkey("Height", "Thumbs");
$T_med = getkey("Width1", "Thumbs") . "x" . getkey("Height1", "Thumbs");
$T_lg = getkey("Width2", "Thumbs") . "x" . getkey("Height2", "Thumbs");
$Tile_sm = getkey("TilesSmallSize", "Thumbs") . "x" . getkey("TilesSmallSize", "Thumbs");
$Tile_lg = getkey("TilesLargeSize", "Thumbs") . "x" . getkey("TilesLargeSize", "Thumbs");
$T_Det = $T_sm; $T_Det_cap = "Details with Thumbnails #1" . " ($T_sm)";
$views = <<<VIEWS
0|Details
1|Details with Thumbnails #1 ($T_sm)
2|List
3|Small Icons
4|Thumbnails #1 ($T_sm)
5|Thumbnails #2 ($T_med)
6|Thumbnails #3 ($T_lg)
7|Large Icons
8|Small Tiles ($Tile_sm)
9|Large Tiles ($Tile_lg)
VIEWS;
$view = Get('View');
$viewdata = FormatList($views, 'f', "<crlf>", $view . '|*'); // Get current view data line.
$cur_view = GetToken($viewdata, 2, '|', 't', 2);
$thumbsize = gettoken(gettoken($cur_view, "1", ")", "t"), "2","(", "t");
$thumbsize_X = gettoken($thumbsize, "1", "x", "t");$thumbsize_X = $thumbsize_X * $multiple;
$thumbsize_Y = gettoken($thumbsize, "2", "x", "t");$thumbsize_Y = $thumbsize_Y * $multiple;
"_ViewPic";
global $cur_folder, $ea_path;
if (gettokenindex("subs]", caller("caption"), " ", "c") == "1") {$montage_folder = $ea_path; }
else {$montage_folder = $cur_folder; }
makecoffee $montage_folder . "folder.jpg",1,1, 1200, 1200;
wait 2000; makecoffee "";
"_Finish_it";
global $cur_folder, $paths;
sel;
$parent = getpathcomponent(,"component", -1,2);
goto gpc(,"component", -2,1);
selectitems $parent;
#1001;
#1049;
status "Montage completed.";
savethumb($image, "p_i_c_$i.jpg", $thumbsize_X, $thumbsize_Y, "jpg100","5" , 2);
the value "5" is the border width. You can leave it blank like this savethumb($image, "p_i_c_$i.jpg", $thumbsize_X, $thumbsize_Y, "jpg100", , 2);
such that there is no border or change the value to whatever you want like "2" or "3".