Reputation: 37
I'm using Irfanview that can be run through the command line. My problem is as follows:
My batch file:
i_view 32.exe /filelist=c:\test\*.pcx /crop=(1,2,3,4,5) /convert=c:\temp\*.pcx
Where 1 is x axis value, 2 is y axis value, 3 is width, 4 is height and 5 is origin.
I need to batch crop two hundred plus images, but my batch file crops all images to (1,2,3,4,5) specifications whereas i need the values to change depending on which image is being processed. In other words the first image that gets cropped is going to be 3×4 pixels cropped 1 pixel right and 2 pixels up from origin option 5, but I need the next file in the folder to have different values for all five variables of crop command preferably via a csv table or something. Does anyone know if this is possible?
Ps- irfanview has closed its forum to registering new accounts
Upvotes: 0
Views: 1025
Reputation: 80113
@ECHO OFF
SETLOCAL
SET "sourcedir=U:\sourcedir"
SET "destdir=U:\destdir"
SET "filename1=%sourcedir%\q35953462.txt"
FOR /f "usebackqtokens=1-6delims=," %%a IN ("%filename1%") DO (
ECHO(i_view32 %%a /crop=(%%b,%%c,%%d,%%e,%%f^) /convert=%destdir%\%%~na.pcx
)
GOTO :EOF
You would need to change the settings of sourcedir
and destdir
to suit your circumstances.
I used a file named q35953462.txt
containing some dummy data for my testing.
file1.pcx,1,2,3,4,5
file2.pcx,5,4,3,2,1
file3.pcx,2,4,6,8,10
The proposed i_view32
commands are merely echo
ed to the screen. To activate following verification change echo(i_view32
to i_view32
With the file,
read each line and tokenise using ,
as a delimiter. There are 6 tokens, nominated as %%a
and inplicitly %%b
..%%f
I don't know the irfanview
syntax for a single file, so I'll leave the polishing to you.
Note that )
needs to be escaped ^)
because it is within a code block.
Upvotes: 1