executing the imagemagick commands in batch file

Questions and postings pertaining to the usage of ImageMagick regardless of the interface. This includes the command-line utilities, as well as the C and C++ APIs. Usage questions are like "How do I use ImageMagick to create drop shadows?".
Post Reply
sin
Posts: 46
Joined: 2011-04-23T11:06:13-07:00
Authentication code: 8675308

executing the imagemagick commands in batch file

Post 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??
el_supremo
Posts: 1015
Joined: 2005-03-21T21:16:57-07:00

Re: executing the imagemagick commands in batch file

Post 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
Sorry, my ISP shutdown all personal webspace so my MagickWand Examples in C is offline.
See my message in this topic for a link to a zip of all the files.
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: executing the imagemagick commands in batch file

Post 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!
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
sin
Posts: 46
Joined: 2011-04-23T11:06:13-07:00
Authentication code: 8675308

Re: executing the imagemagick commands in batch file

Post 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".
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: executing the imagemagick commands in batch file

Post 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.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
User avatar
whugemann
Posts: 289
Joined: 2011-03-28T07:11:31-07:00
Authentication code: 8675308
Location: Münster, Germany 52°N,7.6°E

Re: executing the imagemagick commands in batch file

Post 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'.
Wolfgang Hugemann
Post Reply