Page 1 of 1

Problem using for loop to round edges

Posted: 2012-04-22T04:54:11-07:00
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.

Re: Problem using for loop to round edges

Posted: 2012-04-22T07:21:07-07:00
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 ^

Re: Problem using for loop to round edges

Posted: 2012-04-22T07:32:30-07:00
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

Re: Problem using for loop to round edges

Posted: 2012-04-22T13:50:50-07:00
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...

Re: Problem using for loop to round edges

Posted: 2012-04-23T17:30:33-07:00
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!