Good command-line but Batch conversion not working?

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
TomTomek
Posts: 5
Joined: 2018-02-28T02:22:14-07:00
Authentication code: 1152

Good command-line but Batch conversion not working?

Post by TomTomek » 2019-06-06T00:55:05-07:00

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? :)

snibgo
Posts: 12437
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

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

Post by snibgo » 2019-06-06T03:15:42-07:00

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 
snibgo's IM pages: im.snibgo.com

Post Reply