Page 1 of 1

Variable argument in a string

Posted: 2018-05-05T16:54:09-07:00
by A-KouZ1
I'm trying to create a thin border around image edge which has margin 16px from its size:

Code: Select all

convert Original\0_0.png -bordercolor none -border 16  -fill none -stroke red -strokewidth 1 -draw "rectangle 0,0 %%w%%,%%h%%" 0_0.png
But it is ended up with error:

Code: Select all

convert Original\0_0.png -bordercolor none -border 16  -fill none -stroke red -strokewidth 1 -draw "rectangle 0,0 %w%,%h%" 0_0.jpg
convert: non-conforming drawing primitive definition `rectangle' @ error/draw.c/DrawImage/3401.
I expect that this is an error when reading %w% but not treated as variable.

What to do to make this works out?

This code runs through batch, so I need escape %w% with %%w%%
ImageMagick v7 - Windows 10

Re: Variable argument in a string

Posted: 2018-05-05T17:02:20-07:00
by muccigrosso
%w, not %w% and magick instead of convert for v 7 functionality.

Not sure it does what you want, but at least no errors for me.

Re: Variable argument in a string

Posted: 2018-05-05T17:06:59-07:00
by A-KouZ1
Oh, that's works out, thanks! 😃
But, however, I can't use lastx and lasty.
I decided to replace w,h with lastx,lasty.
where lastx=w-1; lasty=h-1

There are solution?

Re: Variable argument in a string

Posted: 2018-05-05T17:29:04-07:00
by A-KouZ1
Ok, I had figured the solution myself.

With the use of fx[] in argument:

Code: Select all

magick Original\0_0.png -bordercolor none -border 16  -fill none -stroke red -strokewidth 1 -draw "rectangle 0,0 %%[fx:w-1],%%[fx:h-1]" 0_0.jpg 
Sincerely, thanks anyway. 😀