How to batch composite / round corners?

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?".
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: How to batch composite / round corners?

Post by snibgo »

When you are debugging code, don't "echo off". That's just making things harder for yourself.

You should also say what (if any) error messages you get.

One problem is that you need to escape the parentheses that are within your "convert" : ^( and ^)

EDIT: Or put them in quotes: "(" and ")".
snibgo's IM pages: im.snibgo.com
imagefox87
Posts: 20
Joined: 2016-08-26T13:37:18-07:00
Authentication code: 1151

Re: How to batch composite / round corners?

Post by imagefox87 »

I turned off the echo. However, the script runs fast and then closes. I have no output in my output folder. No errors seen. I added ^ before ( and after ).

Code: Select all

for %%g in (*.png) do ^(
	convert %%g
	^( -size 25x25 xc:black -fill white ^
	   -draw "circle 25,25 25,0" -alpha off ^
	   -write mpr:corner +delete ) ^
	^( -clone 0 -fill white -colorize 100%% ^
	   ^( mpr:corner ) -gravity northwest -compose over -composite ^
	   ^( mpr:corner -rotate 90 )^ -gravity northeast -compose over -composite ^
	   ^( mpr:corner -rotate 180 )^ -gravity southeast -compose over -composite ^
	   ^( mpr:corner -rotate 270 )^ -gravity southwest -compose over -composite ) ^
	-alpha off -compose copy_opacity -composite -compose over ^
	^( +clone -background black -shadow 80x3+5+5 ) ^
	+swap -background none -layers merge +repage  "batch/%%g" ^
)
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: How to batch composite / round corners?

Post by fmw42 »

You have your ^ in the wrong places. They need to come before the ( and before the ) and not after. Also one is missing all together. Look carefully at you code.

You have

Code: Select all

^( mpr:corner -rotate 90 )^
And it should be

Code: Select all

^( mpr:corner -rotate 90 ^)

You also have

Code: Select all

^( mpr:corner )
and it should be

Code: Select all

^( mpr:corner ^)

Escaping means put a special character before the one you want to protect.
imagefox87
Posts: 20
Joined: 2016-08-26T13:37:18-07:00
Authentication code: 1151

Re: How to batch composite / round corners?

Post by imagefox87 »

Ok thanks fixed, but I still have no output:

Code: Select all

for %%g in (*.png) do ^(
	convert %%g
	^( -size 25x25 xc:black -fill white ^
	   -draw "circle 25,25 25,0" -alpha off ^
	   -write mpr:corner +delete ^)
	^( -clone 0 -fill white -colorize 100%% ^
	   ^( mpr:corner ^) -gravity northwest -compose over -composite ^
	   ^( mpr:corner -rotate 90 ^) -gravity northeast -compose over -composite ^
	   ^( mpr:corner -rotate 180 ^) -gravity southeast -compose over -composite ^
	   ^( mpr:corner -rotate 270 ^) -gravity southwest -compose over -composite ^)
	-alpha off -compose copy_opacity -composite -compose over ^
	^( +clone -background black -shadow 80x3+5+5 ^)
	+swap -background none -layers merge +repage  "batch/%%g" ^
^)
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: How to batch composite / round corners?

Post by snibgo »

imagefox87 wrote:for %%g in (*.png) do ^(
No. I said:
snibgo wrote:need to escape the parentheses that are within your "convert"
Not the ones that are outside.
snibgo's IM pages: im.snibgo.com
imagefox87
Posts: 20
Joined: 2016-08-26T13:37:18-07:00
Authentication code: 1151

Re: How to batch composite / round corners?

Post by imagefox87 »

@snibgo, I took out the ^ outside the convert. Still no output.

Code: Select all

for %%g in (*.png) do (
	convert %%g
	null: ^
	^( -size 25x25 xc:black -fill white ^
	   -draw "circle 25,25 25,0" -alpha off ^
	   -write mpr:corner +delete ^)
	^( -clone 0 -fill white -colorize 100%% ^
	   ^( mpr:corner ^) -gravity northwest -compose over -composite ^
	   ^( mpr:corner -rotate 90 ^) -gravity northeast -compose over -composite ^
	   ^( mpr:corner -rotate 180 ^) -gravity southeast -compose over -composite ^
	   ^( mpr:corner -rotate 270 ^) -gravity southwest -compose over -composite ^)
	-alpha off -compose copy_opacity -composite -compose over ^
	^( +clone -background black -shadow 80x3+5+5 ^)
	+swap -background none -layers merge +repage  "batch/%%g" ^
)
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: How to batch composite / round corners?

Post by fmw42 »

you need a ^ after convert %%g at the end of that line. It represents a continuation to a new line and you have a new line after that.

you also need one after

Code: Select all

^( mpr:corner -rotate 270 ^) -gravity southwest -compose over -composite ^)
I do not think you need one at "batch/%%g" ^, but it probably does not matter there
imagefox87
Posts: 20
Joined: 2016-08-26T13:37:18-07:00
Authentication code: 1151

Re: How to batch composite / round corners?

Post by imagefox87 »

Ok here are my errors after adding all the ^ at the right places:

Code: Select all

'(' is not a recognized as an internal or external command,
operable program or batch file.
'+swap'is not recognized is an internal or external command,
operable program or batch file.

Code: Select all

for %%g in (*.png) do (
	convert %%g ^
	null: ^
	^( -size 25x25 xc:black -fill white ^
	   -draw "circle 25,25 25,0" -alpha off ^
	   -write mpr:corner +delete ^)
	^( -clone 0 -fill white -colorize 100%% ^
	   ^( mpr:corner ^) -gravity northwest -compose over -composite ^
	   ^( mpr:corner -rotate 90 ^) -gravity northeast -compose over -composite ^
	   ^( mpr:corner -rotate 180 ^) -gravity southeast -compose over -composite ^
	   ^( mpr:corner -rotate 270 ^) -gravity southwest -compose over -composite ^) ^
	-alpha off -compose copy_opacity -composite -compose over ^
	^( +clone -background black -shadow 80x3+5+5 ^)
	+swap -background none -layers merge +repage  "batch/%%g"
)
Maybe I should just convert the original UNIX shell script to Windows bat.
There was a link in one recent post to a file that converts Linux shell scripts to Windows batch files.
Can anyone please tell me where it is? Because it doesn't show in search results.
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: How to batch composite / round corners?

Post by snibgo »

Jeepers. You need a ^ at the end of each line that logically should be attached to the next one.
'(' is not a recognized as an internal or external command,
operable program or batch file.
This means that Windows isn't passing the open-parens to IM, because the previous line hasn't been continued by a caret character.
snibgo's IM pages: im.snibgo.com
imagefox87
Posts: 20
Joined: 2016-08-26T13:37:18-07:00
Authentication code: 1151

Re: How to batch composite / round corners?

Post by imagefox87 »

Ok, I finally got it to work. Just needed more ^ everywhere! Thank you everyone.
rossdv8
Posts: 47
Joined: 2014-03-12T21:54:20-07:00
Authentication code: 6789

Re: How to batch composite / round corners?

Post by rossdv8 »

This is cleaner than my effort :-)
Post Reply