Problem using for loop to round edges

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
dreadpiratelynx
Posts: 2
Joined: 2012-04-22T04:23:09-07:00
Authentication code: 13

Problem using for loop to round edges

Post by dreadpiratelynx »

Just found this awesome piece of software yesterday, but I've spent the better part of the last several hours trying to figure out how to make a batch file to round the corners on multiple files at once (well, sequentially, but whatever, you know what I mean).

I pulled the code directly from here, and it works perfectly well if I manually enter the file name, but as soon as I try using a for loop, i get a "-compose was unexpected at this time" error.

The code I'm getting this error with is as follows:

Code: Select all

for %%f in (*.png) do (
convert "%%f" ^
( +clone -alpha extract ^
-draw "fill black polygon 0,0 0,15 15,0 fill white circle 15,15 15,0" ^
( +clone -flip ) -compose Multiply -composite ^
( +clone -flop ) -compose Multiply -composite ) ^
-alpha off -compose CopyOpacity -composite "%%f"
)
Anyone have any clue as to what's going on/how I can fix it? Using Windows 7 btw.
HugoRune
Posts: 90
Joined: 2009-03-11T02:45:12-07:00
Authentication code: 8675309

Re: Problem using for loop to round edges

Post by HugoRune »

seeing as the first -compose is just after the first ")", try escaping braces inside the command with ^) and ^(

Edit:
but don't start lines with "^(", use at least a space in front of ^
Last edited by HugoRune on 2012-04-22T07:43:51-07:00, edited 1 time in total.
Bonzo
Posts: 2971
Joined: 2006-05-20T08:08:19-07:00
Location: Cambridge, England

Re: Problem using for loop to round edges

Post by Bonzo »

I wonder if you would be better using mogrify instead of convert - it seems mogrify will not do the job due to image limitations
dreadpiratelynx
Posts: 2
Joined: 2012-04-22T04:23:09-07:00
Authentication code: 13

Re: Problem using for loop to round edges

Post by dreadpiratelynx »

HugoRune wrote:seeing as the first -compose is just after the first ")", try escaping braces inside the command with ^) and ^(

Edit:
but don't start lines with "^(", use at least a space in front of ^
Thanks! Worked like a charm. Just curious as to the reason the escape characters weren't necessary when manually entering a file name, but are here...
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: Problem using for loop to round edges

Post by anthony »

Bonzo wrote:I wonder if you would be better using mogrify instead of convert - it seems mogrify will not do the job due to image limitations
No it will not. IMv6 mogrify takes all images and image creation coders on the command line as beign a source/destination image to be worked on. The command line is parsed twice one for image files, which are run though every non-image option found.

Its sort of stupid, but the result of legacy handlign left from IMv5 days.

The only solution to composing with a second image, is to use -draw image.

See IM Examples, Basics, Mogrify, Alpha Composition using "mogrify"
http://www.imagemagick.org/Usage//basic ... fy_compose



The rest of this discussion was spilt to a new discussion in development forum
ImageMagick v7 development
viewtopic.php?f=2&t=20830&p=83870#p83870


We now return to our regularly scheduled discussion on the users problem!
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
Post Reply