Convert not working in a windows 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
Mad-Halfling

Convert not working in a windows batch file

Post by Mad-Halfling »

Hi, I've got a strange problem and I was wondering if it was a known one, possibly with a solution. I'm using a batch file in windows to do a number of transformations on a couple of images, some of them work but some don't, but they still create the destination file. The odd thing is if I run a line (copied and pasted from the batch file) from the command prompt direct it performs the translation ok. An example is
imconvert -density 450x450 b_trn.gif -black-threshold 100% b_trn_black.png
- I have renamed convert.exe to imconvert.exe to overcome the windows path problem - on this command in the batch file it doesn't convert all the colours (it's a greyscale line graph with a transparent) to black, it only creates the target file. Any ideas?

Thanks

MH
Mad-Halfling

Re: Convert not working in a windows batch file

Post by Mad-Halfling »

Typical, I've just cracked it - been going at this for 1/2 the day and just noticed something after I posted this (so I thought I'd share the issue, in case anyone else has this problem). In the output from a test batch file the % was missing from the line - windows was trying to treat it like a variable, to anyone else using this in batch files you need to replace % with %% in the batch file, then the transformations work ok
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Convert not working in a windows batch file

Post by fmw42 »

Mad-Halfling wrote:Typical, I've just cracked it - been going at this for 1/2 the day and just noticed something after I posted this (so I thought I'd share the issue, in case anyone else has this problem). In the output from a test batch file the % was missing from the line - windows was trying to treat it like a variable, to anyone else using this in batch files you need to replace % with %% in the batch file, then the transformations work ok

see http://www.imagemagick.org/Usage/windows/ for other issues
Post Reply