Page 1 of 2

Irfanview

Posted: 16 Sep 2008 23:28
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.

Re: Irfanview

Posted: 17 Sep 2008 02:23
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!

Re: Irfanview

Posted: 22 Sep 2008 02:49
by serendipity
Unpack contents of IrfanView.zip to scripts folder and launch using ::load "IrfanView".
Note: needs v7.80 or later.
IrfanView.zip
Updated: Nov 18th 2008

Re: Irfanview

Posted: 22 Sep 2008 10:06
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";

Re: Irfanview

Posted: 22 Sep 2008 18:10
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?)

Re: Irfanview

Posted: 22 Sep 2008 21:23
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...

Re: Irfanview

Posted: 12 Oct 2008 18:32
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

Re: Irfanview

Posted: 13 Oct 2008 08:47
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.

Re: IrfanviewSuite

Posted: 14 Nov 2009 21:28
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

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;"

   


Re: Irfanview

Posted: 15 Nov 2009 13:14
by ramza__x
Wow long page, thanks Serendipity!

Re: Irfanview

Posted: 10 Feb 2011 05:51
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.

Re: Irfanview

Posted: 10 Feb 2011 14:30
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.

Re: Irfanview

Posted: 30 Jul 2013 02:04
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.

Re: Irfanview

Posted: 30 Jul 2013 18:45
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.

Re: Irfanview

Posted: 31 Jul 2013 03:24
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.