Page 1 of 1

Good command-line but Batch conversion not working?

Posted: 2019-06-06T00:55:05-07:00
by TomTomek
Hey
I have this command that works and does exactly what I need. But I noticed that when I try to convert it to files automatically (I wrote a GUI for this purpose) a problem arises.
My command looks as follows.

Code: Select all

magick.exe -density 400 "C:\SourceFile.tif"[0] -alpha remove -sample 3500x3500">" -background #000000 "watermark.tiff" -alpha off -resize %[fx:t?u.w*0.35:u.w]x -append -sample 3500x3500">" -quality 75 "C:\TargetFile.jpg"
When it executes this command using CMD everything works fine.
However, when I use my program or a bat file with this command (I made a test to rule out a malfunction of my program), I get this message

Code: Select all

magick.exe: InvalidArgument '-resize' 't? u.w * 0.35: u.w]x' at CLI arg 13 @ error / operation.c / CLISimpleOperatorImage / 3170.
Pasting this command directly in the DOS console causes the SourceFile.tif file to be processed correctly and no error message appears. Why? :)

Re: Good command-line but Batch conversion not working?

Posted: 2019-06-06T03:15:42-07:00
by snibgo
What version of IM, on what platform? I guess IM v7.something, on Windows.

In a BAT script, percent has a special meaning. When you don't want that special meaning, you must double it:

Code: Select all

-resize %%[fx:t?u.w*0.35:u.w]x