Image Stack vs. temp files - "-draw" option

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
stevepugh
Posts: 43
Joined: 2008-01-21T12:34:36-07:00

Image Stack vs. temp files - "-draw" option

Post by stevepugh »

Hi all,

I have a Windows program which currently generates a batch file with three "convert.exe" commands to generate two temporary image files and composite them onto a third, finally saving the third one out and deleting the temp files.

To streamline things and stick to just one execution of "convert.exe", I love the idea of using an image stack. However, when I replace the name of the temp file with what I believe to be the correct syntax for an image stack, I get the error "convert.exe: option requires an argument '-draw'"

I used to have the following on one line -

Code: Select all

convert -size 700x260 -background transparent -fill White -font Arial -pointsize 40 caption:"hello" tempfile.jpg
and that was followed by another convert, which included "-draw image over 915.640.0.0 tempfile.jpg"

Now I have the following -

Code: Select all

-draw "image over 915,640 0,0 (-size 700x260 -background transparent -fill White -font Arial -pointsize 40 caption:"hello")"
This is where I get the error "convert.exe: option requires an argument '-draw'"
Is this philosophically correct? Am I doomed to a life without the joy and light that is image stacking?

Best,
Steve
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Image Stack vs. temp files - "-draw" option

Post by fmw42 »

I am not sure this is your problem, but parentheses need to have a space before and after them. The stuff inside the parens needs to have a white space between it and the parens. In your example that does not appear to be the case.

Not sure of this either, but you may need to escape the double quotes around "hello"
el_supremo
Posts: 1015
Joined: 2005-03-21T21:16:57-07:00

Re: Image Stack vs. temp files - "-draw" option

Post by el_supremo »

I'm pretty sure you can't do that sort of substitution of an image filename inside a -draw command, so your philosophy is incorrect. Even if you escaped the quotes around hello (or removed them) and added spaces around the brackets it still wouldn't work.

However, all is not lost. I'm pretty sure that you could use a -composite in place of the -draw because that's basically what it's doing anyway. I think this would work in place of your -draw "image .....":

Code: Select all

( -size 700x260 -background transparent -fill White -font Arial -pointsize 40 caption:"hello" ) -geometry +915+640 -compose over -composite
Pete
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Image Stack vs. temp files - "-draw" option

Post by fmw42 »

yes, -draw is more restrictive, but it ought to work in -composite.

Alternately, I am not sure, but you may get away with the following in a -draw, namely, use a string or its equivalent

-draw "image over 915,640 0,0 $(convert -size 700x260 -background transparent -fill White -font Arial -pointsize 40 caption:"hello")"

but then this is really doing two converts again, just in one command line
stevepugh
Posts: 43
Joined: 2008-01-21T12:34:36-07:00

Re: Image Stack vs. temp files - "-draw" option

Post by stevepugh »

Indeed, '-compose' with the image stack works just like I'd hoped. Thanks, y'all, for all of your help!!

Best,
Steve
Post Reply