Irfanview

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

Irfanview

Post by serendipity »

Ofcourse there are many many commandline options in Irfanview, but I am sharing ones I use most frequently.

Code: Select all

"Rotate right"  
   msg "This will rotate image 90 degrees right and overwrite file, continue?",1;
   openwith """C:\Program Files\IrfanView\i_view32.exe"" <curitem> /jpg_rotate=(3,1) /killmesoftly";
   
"Rotate left"
   msg "This will rotate image 90 degrees left and overwrite file, continue?",1;
   openwith """C:\Program Files\IrfanView\i_view32.exe"" <curitem> /jpg_rotate=(5,1) /killmesoftly";
   
"Slide show"
  inputfolder $folder, <curpath>, Select folder for slide show;
  getkey $irfdelay, "AutoDelay", "slideshow", "C:\Program Files\IrfanView\i_view32.ini";
  input $userdelay, "Set slideshow delay (in seconds)", $irfdelay;
  setkey $userdelay, "AutoDelay", "slideshow", "C:\Program Files\IrfanView\i_view32.ini";
  openwith """C:\Program Files\IrfanView\i_view32.exe""/slideshow=$folder /closeslideshow";

"Slide show (selected files)"
  focus;
  //Copy file/path to clipboard
  #101;
  //Paste clipboard to file
  #219;
  focus;
  set $slideshowtext, <curitem>;
  getkey $irfdelay, "AutoDelay", "slideshow", "C:\Program Files\IrfanView\i_view32.ini";
  input $userdelay, "Set slideshow delay (in seconds)", $irfdelay;
  setkey $userdelay, "AutoDelay", "slideshow", "C:\Program Files\IrfanView\i_view32.ini";
  openwith """C:\Program Files\IrfanView\i_view32.exe""/slideshow=$slideshowtext /closeslideshow";
  delete 0,1, $slideshowtext;

- 
"Edit script : edit"
   self $ScriptFile, file;
   Open $ScriptFile,w

"Cancel"
   
Feel free to add more to the list if you like.
Last edited by serendipity on 17 Sep 2008 19:44, edited 1 time in total.

TheQwerty
Posts: 4373
Joined: 03 Aug 2007 22:30

Re: Irfanview

Post by TheQwerty »

You know I have Irfanview and never use it, but if it rotates images well I may just have to start.

Thanks for sharing!

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

Re: Irfanview

Post by serendipity »

Unpack contents of IrfanView.zip to scripts folder and launch using ::load "IrfanView".
Note: needs v7.80 or later.
IrfanView.zip
(2.82 KiB) Downloaded 200 times
Updated: Nov 18th 2008
Last edited by serendipity on 18 Nov 2008 18:28, edited 7 times in total.

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

Re: Irfanview

Post by admin »

serendipity wrote:Note: needs v7.60.0022 or later.
Tip: Put this as first line of script to make that point clear:

Code: Select all

assert <xyver> >= "7.60.0022";

jacky
XYwiki Master
Posts: 3106
Joined: 23 Aug 2005 22:25
Location: France
Contact:

Re: Irfanview

Post by jacky »

admin wrote:
serendipity wrote:Note: needs v7.60.0022 or later.
Tip: Put this as first line of script to make that point clear:

Code: Select all

assert <xyver> >= "7.60.0022";
Right, you know that's a good idea, but incorrectly done though I believe...
soon wrote:

Code: Select all

$minimum = "7.60.0015"; replace $minver, $minimum, ".", ""; replace $xyver, <xyver>, ".", ""; assert ($xyver >= $minver), "XY too old! Continue at your own risk", 1; status "Something that could fail with versions older than $minimum...";
:# Set the minimum required version of XY to run the script in variable $minimum
:# Removes all dots from that number and stores it into $minver
:# Removes all dots from XY version number and stores it into $xyver
:# Ensures that the current XY is at least the minimum required, interrupts execution otherwise
:# Shows a message on statusbar

Note: Remember that we are talking mathematics here for comparisons, so you cannot compare version numbers (i.e. strings) directly, you need to first turn them into comparable values, i.e. numbers, hence the removing of all dots.
Right? (I mean sure it seems to work fine for now comparing strings, but (a) I'm not sure if this couldn't change later on, as it appears to me not really a reliable thing, and (b) once XY will be v10 there will be serious issues, and (c) it just isn't right, is it?)
Proud XYplorer Fanatic

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

Re: Irfanview

Post by admin »

jacky wrote:
admin wrote:
serendipity wrote:Note: needs v7.60.0022 or later.
Tip: Put this as first line of script to make that point clear:

Code: Select all

assert <xyver> >= "7.60.0022";
Right, you know that's a good idea, but incorrectly done though I believe...
soon wrote:

Code: Select all

$minimum = "7.60.0015"; replace $minver, $minimum, ".", ""; replace $xyver, <xyver>, ".", ""; assert ($xyver >= $minver), "XY too old! Continue at your own risk", 1; status "Something that could fail with versions older than $minimum...";
:# Set the minimum required version of XY to run the script in variable $minimum
:# Removes all dots from that number and stores it into $minver
:# Removes all dots from XY version number and stores it into $xyver
:# Ensures that the current XY is at least the minimum required, interrupts execution otherwise
:# Shows a message on statusbar

Note: Remember that we are talking mathematics here for comparisons, so you cannot compare version numbers (i.e. strings) directly, you need to first turn them into comparable values, i.e. numbers, hence the removing of all dots.
Right? (I mean sure it seems to work fine for now comparing strings, but (a) I'm not sure if this couldn't change later on, as it appears to me not really a reliable thing, and (b) once XY will be v10 there will be serious issues, and (c) it just isn't right, is it?)
v10 will be vA.00.0000, of course! :wink: That gives us a couple of more years...

jacky
XYwiki Master
Posts: 3106
Joined: 23 Aug 2005 22:25
Location: France
Contact:

Re: Irfanview

Post by jacky »

hmmm...

Code: Select all

::echo compare("10.20.0025", "7.60.0026", "v");
According to the changelog this should return 1, since 10 > 7, but over here it returns -1

Just like

Code: Select all

::echo compare("7.60.0026", "10.20.0025", "v"); 
should be -1 (since 7 < 10) yet it returns 1 !

Seems to me like "v" and "b" modes are the same! :?

Code: Select all

  msg compare("2", "12", v); // returns 1
  msg compare("2.00.0000", "12.00.0000", v); // returns 1
Proud XYplorer Fanatic

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

Re: Irfanview

Post by admin »

jacky wrote:hmmm...

Code: Select all

::echo compare("10.20.0025", "7.60.0026", "v");
According to the changelog this should return 1, since 10 > 7, but over here it returns -1

Just like

Code: Select all

::echo compare("7.60.0026", "10.20.0025", "v"); 
should be -1 (since 7 < 10) yet it returns 1 !

Seems to me like "v" and "b" modes are the same! :?

Code: Select all

  msg compare("2", "12", v); // returns 1
  msg compare("2.00.0000", "12.00.0000", v); // returns 1
Whoops. The fix in v7.60.0032 - 2008-09-27 20:26 spoiled the originally working functions.

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

Re: IrfanviewSuite

Post by serendipity »

Updated the old script with IF/ELSE/WHILE. Just change the path to Irfanview exe and you are good to go.
Download:
IrfanViewSuite.xys
(10.92 KiB) Downloaded 213 times

Code: Select all

//IrfanViewScript - version 3
// Needs atleast XYplorer version 8.60

"_assert : _assert"
  $minimum = "8.60.0000"; $compatible = (compare(<xyver>, $minimum, v) == -1) ? 0 : 1; assert ($compatible), "XY too old! Continue at your own risk", 1;
  global $g_IrfanPath;

//!!!IMPORTANT!!!
//Set the Irfanview file path below
  $g_IrfanPath="c:\Program Files (x86)\IrfanView\i_view32.exe";

"IrfanViewSuite v3|i_view32 /8 : IrfanView"
    sub _assert;
    load *, "IrfanView;readme;-;rotate;RotateR;RotateL;RotateV;RotateH;-;slideshow;slide;-;convert;con;-;resize;res;-;panorama;l2r;t2b;-;imageinfo;allinfo;Individualinfo;-;edit;can;"


"(Read Me) : readme"
  sub _assert;
  Text "!!!REMINDER!!!: Change the Irfanview path in the script. <br><br>What does this script do? <br><br>
 1) ROTATE: <br> - Rotates selected images to 90, 180 and 270 degrees and also creates mirror image. <br> - You can choose to backup files before resizing, else they will be overwritten. <br><br>
 2) SLIDESHOW: <br> - Displays a slideshow of selected or all images in a folder. <br> - You can control the slideshow speed. <br> - You can run a slideshow from search tab too. <br><br>
 3) CONVERT: <br> - Converts selected images to another filetype. For example, from png, jpeg > gif. <br> - You can choose to backup files before resizing, else they will be overwritten.<br><br>
 4) RESIZE: <br> - Resizes selected images to different size. <br> - Aspect ratio is preserved. For example if you type width as 300 and height as 2, then 2 is ignored. <br> - You can choose to backup files before resizing, else they will be overwritten.<br><br>
 5) PANORAMA: <br> - Create a panorama, i.e. joins selected images next to each other. <br> - You have the option to create vertical (top-to-bottom) or horizontal (left-to-right) panorama<br> - Original files will not be altered  <br><br>
 6) IMAGEINFO: <br> - Writes image info to a text file. <br> - You have two options: Write all image info to one text file or write selected image info to their respective text files. <br> - Sorry, info for selected files cannot be written to one text file.", 600,650, Info about IrfanViewSuite v3, w;


"-"

  /*ROTATE SCRIPTS: START*/
"&1. ROTATE|i_view32 /1 : rotate"
  sub _assert;
  load *, "rotate;-;RotateR;RotateL;RotateV;RotateH;-;_back;can;"

"  - Right : RotateR"  
   sub _assert;
   global $g_IrfanPath;
   
   $count= getinfo("CountSelected");

   IF ($count==0){
   sub "_unselected";
   }

   ELSE {
   $selected=getinfo("SelectedItemsNames", "|");
   filter "$selected";
   }

   IF (confirm("Click 'OK' to overwrite current files or 'Cancel' to backup files")==1) {
   sel 1;
   }

   ELSE {
   focus;
   input $backup, "Backup files to <curpath>\originals (or change below)", "<curpath>\originals";
   backupto "$backup";
   sel 1;
   }

   $curpos = 0;
   WHILE ($count > $curpos){
   $curpos = getinfo ("FocusedPos");
   run """$g_IrfanPath""<curitem> /rotate_r /convert <curitem> /killmesoftly",,1;
   sel +1;
   }
   filter;
   status "Rotation finished";
   focus c;

   
"  - Left : RotateL"
   sub _assert;
   global $g_IrfanPath;
   $count= getinfo("CountSelected");

   IF ($count==0){
   sub "_unselected";
   }

   ELSE {
   $selected=getinfo("SelectedItemsNames", "|");
   filter "$selected";
   }

   IF (confirm("Click 'OK' to overwrite current files or 'Cancel' to backup files")==1) {
   sel 1;
   }

   ELSE {
   focus;
   input $backup, "Backup files to <curpath>\originals (or change below)", "<curpath>\originals";
   backupto "$backup";
   sel 1;
   }

   $curpos = 0;
   WHILE ($count > $curpos){
   $curpos = getinfo ("FocusedPos");
   run """$g_IrfanPath""<curitem> /rotate_l /convert <curitem> /killmesoftly",,1;
   sel +1;
   }
   filter;
   status "Rotation finished";
   focus c;
    

   
"  - Upside-Down : RotateV"  
   sub _assert;
   global $g_IrfanPath;
   $count= getinfo("CountSelected");

   IF ($count==0){
   sub "_unselected";
   }

   ELSE {
   $selected=getinfo("SelectedItemsNames", "|");
   filter "$selected";
   }

   IF (confirm("Click 'OK' to overwrite current files or 'Cancel' to backup files")==1) {
   sel 1;
   }

   ELSE {
   focus;
   input $backup, "Backup files to <curpath>\originals (or change below)", "<curpath>\originals";
   backupto "$backup";
   sel 1;
   }

   $curpos = 0;
   WHILE ($count > $curpos){
   $curpos = getinfo ("FocusedPos");
   run """$g_IrfanPath""<curitem> /rotate_r /convert <curitem> /killmesoftly",,1;
   run """$g_IrfanPath""<curitem> /rotate_r /convert <curitem> /killmesoftly",,1;
   sel +1;
   }
   filter;
   status "Rotation finished";
   focus c;
   
  

"  - Mirror-Image (JPG Only) : RotateH"  
   sub _assert;
   global $g_IrfanPath;
   $count= getinfo("CountSelected");

   IF ($count==0){
   sub "_unselected";
   }

   ELSE {
   $selected=getinfo("SelectedItemsNames", "|");
   filter "$selected";
   }

   IF (confirm("Click 'OK' to overwrite current files or 'Cancel' to backup files")==1) {
   sel 1;
   }

   ELSE {
   focus;
   input $backup, "Backup files to <curpath>\originals (or change below)", "<curpath>\originals";
   backupto "$backup";
   sel 1;
   }

   $curpos = 0;
   WHILE ($count > $curpos){
   $curpos = getinfo ("FocusedPos");
   run """$g_IrfanPath"" <curitem> /jpg_rotate=(2,1) /killmesoftly",,1;
   sel +1;
   }
   filter;
   status "Rotation finished";
   focus c;

  
/*ROTATE SCRIPTS : END*/


"-"   

/*SLIDESHOW SCRIPTS : START*/   
"&2. SLIDESHOW|i_view32 /1 : slideshow"
  sub _assert;
    load *, "slideshow;-;slide;-;_back;can;"
  
"- Slideshow : slide"
   sub _assert;
   global $g_IrfanPath;
   focus;
   $count= getinfo("CountSelected");
   IF ($count == 0) {
   getkey $irfdelay, "AutoDelay", "slideshow", "C:\Program Files\IrfanView\i_view32.ini";
  input $userdelay, "Set slideshow delay (in seconds)", $irfdelay;
  setkey $userdelay, "AutoDelay", "slideshow", "C:\Program Files\IrfanView\i_view32.ini";
  run """$g_IrfanPath""/slideshow=<curpath> /closeslideshow";
  }
  
  ELSE {
  focus;
  $count= getinfo("CountSelected");
  #101;
  #219;
  set $slideshowtext, <curitem>;
  getkey $irfdelay, "AutoDelay", "slideshow", "C:\Program Files (x86)\IrfanView\i_view32.ini";
  input $userdelay, "Set slideshow delay (in seconds)", $irfdelay;
  setkey $userdelay, "AutoDelay", "slideshow", "C:\Program Files (x86)\IrfanView\i_view32.ini";
  run """$g_IrfanPath""/slideshow=$slideshowtext /closeslideshow ",,1;
  Status "End of Slideshow";
  delete /*No recycle bin*/0, /*Prompt before delete*/0, $slideshowtext;
  }
  
/*SLIDESHOW SCRIPTS : END*/ 

"-"

/*CONVERT SCRIPTS : START*/ 
"&3. CONVERT|i_view32 /2 : convert"
  sub _assert;
   load *, "convert;-;con;-;_back;can;"

"- Convert images : con"
   sub _assert;
   global $g_IrfanPath;
   $count= getinfo("CountSelected");
   IF ($count == 0) {
   sub "_unselected";
   }
 
   ELSE {
   $selected=getinfo("SelectedItemsNames", "|");
   filter "$selected";
   input $ext, "Convert files to which extension? (Current files will not be overwritten)", gif;
   sel 1;
   $curpos=0;
   WHILE ($count > $curpos) {
   $curpos= getinfo ("FocusedPos");
   run """$g_IrfanPath""<curitem> /convert=<curpath>\<curbase>.$ext",,1;
   sel +1;
   }
   }
   
   filter;
   status "Conversion finished"   
   
/*CONVERT SCRIPTS : END*/     
"-"

/*RESIZE SCRIPTS : START*/ 
"&4. RESIZE|i_view32 /2 : resize"
  sub _assert;
    load *, "resize;-;res;-;_back;can;"
  
"- Resize images : res"
    sub _assert;
    global $g_IrfanPath;
    $count= getinfo("CountSelected");
   IF ($count == 0) {
   sub "_unselected";
   }
   
   ELSE {
   $selected=getinfo("SelectedItemsNames", "|");
   filter "$selected";
   focus;
   input $backup, "Before resizing original files will be backed up to <curpath>\originals (you can change this below)", "<curpath>\originals";
   backupto "<curpath>\originals";
   input $dimensions, "Convert files to what dimensions (width, height)? (Current files will not be overwritten)", "(300 ,300)";
   sel 1;
   $curpos=0;
   WHILE ($count > $curpos) {
   $curpos = getinfo ("FocusedPos");
   run """$g_IrfanPath""<curitem> /resize=$dimensions /aspectratio /resample /convert <curitem> /killmesoftly",,1;
   sel +1;
   }
   }
   filter;
   status "Conversion finished"   
   
/*RESIZE SCRIPTS : END*/

"-" 
/*PANORAMA SCRIPTS : START*/
   
"&5. PANORAMA|i_view32 /1 : panorama"
   sub _assert;
    load *, "panorama;-;l2r;t2b;-;_back;can;"
   
" - Left-to-Right : l2r"      
   sub _assert;
   global $g_IrfanPath;
    focus;
   $count= getinfo("CountSelected");
   IF ($count == 0) {
   sub "_unselected";
   }

   ELSEIF ($count == 1) {
   status "Select atleast two files", ,alert;
   end 1==1, "Cannot create panorama with one file. <crlf>Select atleast two files";
   }
   
   ELSE {
   $selected=getinfo("SelectedItemsPathNames", ",");
   substr $selected, $selected, 0,-1;
   run """$g_IrfanPath"" /panorama=(1,$selected) /convert ""<curpath>\panorama.jpg"" /silent",,1;
   Status "panorama.jpg created!";
   }

" - Top-to-Bottom : t2b"
   sub _assert;
   global $g_IrfanPath;
    $count= getinfo("CountSelected");
   IF ($count == 0) {
   sub "_unselected";
   }

   ELSEIF ($count == 1) {
   status "Select atleast two files", ,alert;
   end 1==1, "Cannot create panorama with one file. <crlf>Select atleast two files";
   }
   
   ELSE {
   $selected=getinfo("SelectedItemsPathNames", ",");
   run """$g_IrfanPath"" /panorama=(2,$selected) /convert ""<curpath>\panorama.jpg"" /silent",,1;
   Status "panorama.jpg created!";
   }


/*PANORAMA SCRIPTS : END*/
"-"   
/*IMAGEINFO SCRIPTS : START*/
"&6. IMAGE INFO|i_view32 /1 : imageinfo"
    sub _assert;
    load *, "imageinfo;-;allinfo;Individualinfo;-;_back;can;"

" - All : allinfo"  
    sub _assert;
    global $g_IrfanPath;
    run """$g_IrfanPath""<curpath>\*.* /info=""<curpath>\ImageInfo.txt"" /silent /killmesoftly",,1; 

" - Individual : Individualinfo"  
   sub _assert;
   global $g_IrfanPath;
    
   $count= getinfo("CountSelected");
   IF ($count == 0) {
   sub "_unselected";
   }

   ELSE {
   $selected=getinfo("SelectedItemsNames", "|");
   filter "$selected";
   sel 1;
   $curpos=0;
   WHILE ($count > $curpos){
   $curpos= getinfo ("FocusedPos");
   run """$g_IrfanPath""<curitem> /info=<curpath>\<curbase>.txt /killmesoftly",,1;
   sel +1;
   }
   }
   filter;
   status "Info ready" 
   
/*IMAGEINFO SCRIPTS : END*/   
"-" 
"Edit script|:udc : edit"
   self $ScriptFile, file;
   Open $ScriptFile,w

"Cancel|:stop : can"


"_Unselected : _unselected"
   status "Select atleast one file", ,alert;
   end 1==1, "No files selected";

 
"Back|:back : _back"
        load *, "IrfanView;readme;-;rotate;RotateR;RotateL;RotateV;RotateH;-;slideshow;slide;-;convert;con;-;resize;res;-;panorama;l2r;t2b;-;imageinfo;allinfo;Individualinfo;-;edit;can;"

   


ramza__x
Posts: 84
Joined: 06 Oct 2007 02:21
Location: Australia

Re: Irfanview

Post by ramza__x »

Wow long page, thanks Serendipity!
Attachments
wow serendipity!.png
wow serendipity!.png (31.26 KiB) Viewed 4291 times
Windows XP Pro (SP3) (x86)
1680x1050 Res /120 DPI, Acer Laptop

aimy
Posts: 183
Joined: 26 Feb 2007 15:44

Re: Irfanview

Post by aimy »

Dear serendipity,

Can this script be extended to rename list of files using the EXIF info?

Original idea..

Code: Select all

http://www.xyplorer.com/xyfc/viewtopic.php?f=3&t=6135
Thank you.

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

Re: Irfanview

Post by serendipity »

aimy wrote:Dear serendipity,

Can this script be extended to rename list of files using the EXIF info?

Original idea..

Code: Select all

http://www.xyplorer.com/xyfc/viewtopic.php?f=3&t=6135
Thank you.
I'll give it a try, but cannot promise as I am going to go on a vacation.

kiwichick
Posts: 557
Joined: 08 Aug 2012 04:14
Location: Pahiatua, New Zealand

Re: Irfanview

Post by kiwichick »

I realise this is a very old thread but I really love the idea of an IrfanViewSuite :appl: I imagine some of the scripting has changed since this was written so is there any chance you could take a look and update it???? I haven't tried everything but I found that rotation doesn't work on multiple images - it just goes into an endless loop of rotating the last selected image.
Windows 10 Pro 22H2

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

Re: Irfanview

Post by serendipity »

kiwichick wrote:I realise this is a very old thread but I really love the idea of an IrfanViewSuite :appl: I imagine some of the scripting has changed since this was written so is there any chance you could take a look and update it???? I haven't tried everything but I found that rotation doesn't work on multiple images - it just goes into an endless loop of rotating the last selected image.
Thanks! I've not been updating this that much. I'll check that rotation thing when i get some time off next week.
Btw, XY already has the rotation option built-in.

kiwichick
Posts: 557
Joined: 08 Aug 2012 04:14
Location: Pahiatua, New Zealand

Re: Irfanview

Post by kiwichick »

Thanks for that, just whenever you have the time would be great :biggrin: And thanks for the heads up about XYplorer's built-in feature. A script does allow for adding other actions though, which is very handy.
Windows 10 Pro 22H2

Post Reply