Page 1 of 1

executing the imagemagick commands in batch file

Posted: 2011-05-30T07:15:40-07:00
by sin
i have around 7 IM commands to be executed one after the other. i have written them in .bat file and started executing them in the command prompt. there all commands were executing but they are not working. but the result makes no difference before and after the execution.

Should I need to make changes in the file

my file looks like this:

convert 27.jpg -resize 240x320 27.png
convert 27.png -fuzz 50% -fill white -opaque white 27_f.png
convert 27_f.png -transparent white 27_tr.png
convert 27_tr.png -alpha extract -edge 2 27_alpha.png
convert 27_alpha.png 27_alpha.txt

what do i need to inlcude??

Re: executing the imagemagick commands in batch file

Posted: 2011-05-30T09:16:12-07:00
by el_supremo
Windows also has its own convert command and your batch script may be executing that instead of the ImageMagick version.
Try copying the Imagemagick convert.exe to imconvert.exe and then change your batch script to use imconvert instead of convert.

Pete

Re: executing the imagemagick commands in batch file

Posted: 2011-05-30T19:06:14-07:00
by anthony
Also double the '%'

Other than that you can concatenate the options..

Code: Select all

  convert 27.jpg -resize 240x320^
           -fuzz 50%% -fill white -opaque white ^
          -fuzz 0 -transparent white ^
          -alpha extract -edge 2 ^
          27_alpha.txt
The operation sequence is a little strange what is wrong with...

Code: Select all

  ... -fuzz 50%% -fill white -opaque white -fill black +opaque white ...
+opaque white means anything not within 50% (current fuzz setting) white!

Re: executing the imagemagick commands in batch file

Posted: 2011-05-31T02:48:56-07:00
by sin
anthony wrote:Also double the '%'

Other than that you can concatenate the options..

Code: Select all

  convert 27.jpg -resize 240x320^
           -fuzz 50%% -fill white -opaque white ^
          -fuzz 0 -transparent white ^
          -alpha extract -edge 2 ^
          27_alpha.txt
The operation sequence is a little strange what is wrong with...

Code: Select all

  ... -fuzz 50%% -fill white -opaque white -fill black +opaque white ...
+opaque white means anything not within 50% (current fuzz setting) white!
Thanq.

But can I write the code in such a way that the while executing it must ask for the "input file name".

Re: executing the imagemagick commands in batch file

Posted: 2011-05-31T17:03:34-07:00
by anthony
sin wrote:But can I write the code in such a way that the while executing it must ask for the "input file name".
No. IM has no method of prompting or reading input like that. That is something that the wrapper program (DOS, Shell, PHP, etc) would need to do.

Re: executing the imagemagick commands in batch file

Posted: 2011-06-01T15:31:44-07:00
by whugemann
I can't see what's wrong with your batch file, aside from the two percent signs (50%%) as Anthony said already.

At http://www.imagemagick.org/Usage/windows/#debugging I give a few hints on debugging batch files. As a start, I would recommend starting it within a DOS box, such that you have some feedback on what's really happening.

You can than write a protocol of what's really happening by redirecting the batch file's output to a logfile. Convert writes part of its messages to stderr instead of stdout, such that you have to redirect both stdout and stderr to the logfile. Assuming that your batch is named 'mybatch.bat', you should run a command like

Code: Select all

mybatch>>output.log 2>&1
which redirects both, stdout and stderr, to the file 'output.log'.