Page 1 of 1
need a help for a UDC to Irfan view
Posted: 05 Nov 2009 11:33
by calude
Hi
trying to send a command line to Irfanview so it creates a thumb from a jpg
here is the command set in Openwith in XY
"C:\Program Files\iview410\i_view32.exe" <curitem> /resize=(160,100) /resample /aspectratio /convert=<curitempath>\tn_$N.jpg
irfanview complains:
JPG Save error !
Can't open file for writing: "E:\G9\20080516\tn_img_1536.jpg "E_\G9\20080516\img_1536.JPG"
the path seem correct.
the example given by the IfV help is :
i_view32.exe c:\test.bmp /resize=(100,100) /resample /aspectratio /convert=d:\$N_thumb.jpg
Any Idea ??
Thanks
Calude
Re: need a help for a UDC to Irfan view
Posted: 05 Nov 2009 11:58
by zer0
Here's the correct code

Code: Select all
OpenWith("""C:\Program Files\iview410\i_view32.exe"" <items> /resize=(160,100) /resample /aspectratio /convert=<curitempath>\tn_$N.jpg", "s");
Re: need a help for a UDC to Irfan view
Posted: 05 Nov 2009 12:25
by calude
Indeed it works
thanks Zer0
why did you choose to use a script instead of a command line from user/openWith wich I was investigating ??
Calude
Re: need a help for a UDC to Irfan view
Posted: 05 Nov 2009 13:27
by zer0
calude wrote:why did you choose to use a script instead of a command line from user/openWith wich I was investigating??
Essentially, they both achieve the same outcome. Also, I like to rope in extra things so having a script offered the most flexibility, i.e. personal choice. Last but not least, I have no OpenWith UDCs, but I have scripts that do OpenWith, so it was a quick copy/paste with a little editing

Re: need a help for a UDC to Irfan view
Posted: 20 Jan 2010 10:31
by little titty
Zero thanks for the code, works fine. Is there a way of tweaking it so that if I select a group of photos in a folder it will make the same size thumbnails of them all? If I try that with the current script IView complains "cant read file header"
Re: need a help for a UDC to Irfan view
Posted: 20 Jan 2010 11:18
by zer0
little titty wrote:Zero thanks for the code, works fine. Is there a way of tweaking it so that if I select a group of photos in a folder it will make the same size thumbnails of them all? If I try that with the current script IView complains "cant read file header"
Yep, that's because the current script passes to a single instance of an application. Technically, it shouldn't even have "<items>" (it should be "<curitempath>"), because a single instance of IrfanView doesn't process multiple items in the way that XYplorer passes them. For multiple photo -> thumbnail processing, you have several options (some are better than others, you choose

):
a) Try using "m" switch in the current script, so each file
should be passed to its own instance of IrfanView. Not quite efficient, but easy and quick.
b) If you're processing all files of one format (JPG/PNG/WhateverG) then you can use "PATH TO YOUR FILES\*.FILE_EXTENSION" i.e. "c:\*.jpg" instead of "<items>".
c) The best solution, it involves more work though, is to create a script that would loop through the List-selected items to create a text file with each file name on a new line. This file should then be passed to IrfanView like "/filelist=c:\files _to process.txt", so no need for "<items>". In this case, you can (maybe even should, but your call) use "run" instead of "OpenWith", because "run" has a "wait" switch, so you can have XY's script wait until IrfanView finishes processing files and then tidy things up: delete images from which thumbs were made, delete the created TXT file or what you wish
P.S. I'd post a script to do c) later (mind on other things, no time to test), but another scripts' writer is welcome to do that if it's urgent

Re: need a help for a UDC to Irfan view
Posted: 20 Jan 2010 12:08
by little titty
HI, thanks for the reply, I will try option B as option c is beyond me!
Yes I was meaning a script for one file type, .jpg
It would just be handy when having to make a few thumbnails for putting pictures on my website.
yes option B works fine. but it means i always have to put the files in a certain dir first
now I just need a script that would automatically put the files I select in a certain folder!
just curious but in option A, what is the m switch?
Re: need a help for a UDC to Irfan view
Posted: 21 Jan 2010 00:32
by zer0
little titty wrote:yes option B works fine. but it means i always have to put the files in a certain dir first
now I just need a script that would automatically put the files I select in a certain folder!
The script below will create a text file with a list of files that you have selected. Just pass that list to IrfanView and no need to create folders and move files to them
Code: Select all
$filelist = getinfo("SelectedItemsPathNames");
writefile("files.txt", "$filelist");
little titty wrote:just curious but in option A, what is the m switch?
As per Help file
m: Multiple instance (pass each of the items to its own instance of the application).
Re: need a help for a UDC to Irfan view
Posted: 21 Jan 2010 12:12
by little titty
thanks that seems the best solution
I am curious though why using this script didnt produce the result expected
I wanted to resize the images currently in C:\thumbs and not have them moved but the result is the images are resized and also moved to C:\ why?
Code: Select all
OpenWith("""D:\PROGRAM FILES\IrfanView\i_view32.exe"" c:\thumbs\*.jpg /resize=(160,100) /resample /aspectratio /convert=<curitempath>\tn_$N.jpg", "s");
Re: need a help for a UDC to Irfan view
Posted: 21 Jan 2010 12:36
by zer0
little titty wrote:I am curious though why using this script didnt produce the result expected
I wanted to resize the images currently in C:\thumbs and not have them moved but the result is the images are resized and also moved to C:\ why?
Code: Select all
OpenWith("""D:\PROGRAM FILES\IrfanView\i_view32.exe"" c:\thumbs\*.jpg /resize=(160,100) /resample /aspectratio /convert=<curitempath>\tn_$N.jpg", "s");
Probably because for
<curitempath> in
/convert switch to work it needs for an item to be selected and that never happens (in XY, that is; it's IrfanView that does the selecting). Hard-coding a path or using
<curpath> would be the next best thing methinks.
Re: need a help for a UDC to Irfan view
Posted: 21 Jan 2010 16:07
by little titty
in the end i wrote a .bat file couldnt figure out how to send a list to irfanview - wasnt much in the help file on sending arguments to other progs. could do with more written for newbies to scripting, more examples etc.
anyway with my simple bat file I can just put a bunch of files in a folder and run the bat and it works for me.
Code: Select all
start /wait i_view32.exe C:\thumbs\*.jpg /resize=(500,300) /aspectratio /resample /convert=C:\thumbs\*.jpg
Re: need a help for a UDC to Irfan view
Posted: 21 Jan 2010 16:48
by zer0
little titty wrote:in the end i wrote a .bat file couldnt figure out how to send a list to irfanview - wasnt much in the help file on sending arguments to other progs. could do with more written for newbies to scripting, more examples etc.
anyway with my simple bat file I can just put a bunch of files in a folder and run the bat and it works for me.
Code: Select all
start /wait i_view32.exe C:\thumbs\*.jpg /resize=(500,300) /aspectratio /resample /convert=C:\thumbs\*.jpg
Well, I used the following script to create thumbs from a selection written to a text file (use your own paths, of course

)
Code: Select all
run '"C:\Program Files\IrfanView\i_view32.exe" /filelist=C:\files.txt /resize=(160,100) /resample /aspectratio /convert=C:\thumbs\tn_$N.jpg';
What I did struggle with, however, is passing a location as a parameter instead of hard-coding it. If the location of the written text file list is always the same then I suppose that's tolerable and you can ask XYplorer to wait for shelled process to finish using "1" switch in "run" command and then overwrite the source file list with a blank one. At least you now have it the way you find comfortable.
Regarding scripting for newbies, you should bear in mind that scripting is an advanced topic and it's a challenge to balance the documentation for both newbies and scripting/programming professionals. We try to make it easier by having multiple sources of information (Help file, forum, Wiki, main site) and the forum as means of asking questions about the matter.
Re: need a help for a UDC to Irfan view
Posted: 21 Jan 2010 19:16
by little titty
Thanks very much for that, I now have some idea of the use of a file list, I searched the forum but couldnt find an example. I have used your example to make 2 versions of a script one to copy all files within a folder and resize them and the other to only resize selected files.
Thanks I learned something