Page 1 of 1

Using IrfanView on multiple images

Posted: 17 Aug 2021 01:56
by kiwichick
Hi everyone, I have a script containing pieces of code that use IrfanView to work with image files. The problem is they only work for one file no matter how may are selected and I can't, for the life of me, figure out how to loop them for multiple files. Any help would be greatly appreciated. TIA :grin:

Code: Select all

"Convert To PNG"
   run """C:\PortableApps\IrfanView\i_view32.exe"" <curitem> /resample /convert=""<curpath>\<curbase>.png"" /killmesoftly",,1;

"Convert To JPG"
   run """C:\PortableApps\IrfanView\i_view32.exe"" <curitem> /resample /convert=""<curpath>\<curbase>.jpg"" /killmesoftly",,1;

"Convert To {input}"
   $format = input("Enter Format to be converted to.",,,s);
   run """C:\PortableApps\IrfanView\i_view32.exe"" <curitem> /resample /convert=""<curpath>\<curbase>.$format"" /killmesoftly",,1;

"Resize - maintain aspect ratio"
   $w = input("Enter new Width","Leave as 0 if new Height is to be entered.",0,s);
   $h = input("Enter new Height","Leave as 0 if new Width has already been entered.",0,s);
   run """C:\PortableApps\IrfanView\i_view32.exe"" <curitem> /resize=($w,$h) /resample /aspectratio /convert <curitem> /killmesoftly",,1;

"Resize - ignore aspect ratio"
   $w = input("New Width",,,s);
   $h = input("New Height",,,s);
   run """C:\PortableApps\IrfanView\i_view32.exe"" <curitem> /resize=($w,$h) /resample /convert <curitem> /killmesoftly",,1;
  
"Create multipage PDF from input files"
   copytext get("SelectedItemsNames", ",");
   run """C:\PortableApps\IrfanView\i_view32.exe"" /multipdf=(<curpath>\test.pdf,<clipboard>)";

"Slideshow"
   $imagesfolder = inputfolder("C:\ABBA\ABBA Pics\_Wallpaper\Wallpaper 1366x768", "Select folder for slideshow");
   run """C:\PortableApps\IrfanView\i_view32.exe"" /slideshow=""$imagesfolder""" /closeslideshow,,1;
   
"Get image info"
   $txt = "<curpath>\<curbase>info.txt";
   run """C:\PortableApps\IrfanView\i_view32.exe""<curitem> /info=$txt /killmesoftly",,1;
   open "$txt";

Re: Using IrfanView on multiple images

Posted: 17 Aug 2021 07:25
by highend

Code: Select all

    foreach($item, <get SelectedItemsPathNames>, <crlf>, "e") {
        $path = gpc($item, "path");
        $base = gpc($item, "base");
        run """C:\PortableApps\IrfanView\i_view32.exe"" ""$item"" /resample /convert=""$path\$base.png"" /killmesoftly",,1;
    }

Re: Using IrfanView on multiple images

Posted: 18 Aug 2021 01:23
by kiwichick
highend wrote: ↑17 Aug 2021 07:25

Code: Select all

    foreach($item, <get SelectedItemsPathNames>, <crlf>, "e") {
        $path = gpc($item, "path");
        $base = gpc($item, "base");
        run """C:\PortableApps\IrfanView\i_view32.exe"" ""$item"" /resample /convert=""$path\$base.png"" /killmesoftly",,1;
    }
Thank you so much highend, I almost had it sorted myself but was obviously having a bit of a brain fart. I was changing the first <cur...> after the IrfanView path but forgot to change all the other <cur...> parts.