Page 1 of 1

Percent escape and strokewidth

Posted: 2017-03-14T13:31:34-07:00
by Videomajk
I'm trying to draw a rectangle with a variable strokewidth using a percent escape like this (win bat-file formated, therefore the double %-signs):

Code: Select all

magick source.jpg^	
	-set option:tjock %%[fx:h*0,03] ^
	-bordercolor black ^
	-stroke black ^
	-strokewidth %%[tjock] ^
	-draw "rectangle 10,10 100,100" ^
test.jpg
It doesn't work, the rectangle gets a width of 1 pixel regardless the height of the source image. I suppose -strokewidth doesn’t support percent escapes. Is there Another way of accomplishing this?

Re: Percent escape and strokewidth

Posted: 2017-03-14T14:06:54-07:00
by GeeMack
Videomajk wrote: 2017-03-14T13:31:34-07:00

Code: Select all

magick source.jpg^	
	-set option:tjock %%[fx:h*0,03] ^
	-bordercolor black ^
	-stroke black ^
	-strokewidth %%[tjock] ^
	-draw "rectangle 10,10 100,100" ^
test.jpg
It doesn't work, the rectangle gets a width of 1 pixel regardless the height of the source image. I suppose -strokewidth doesn’t support percent escapes. Is there Another way of accomplishing this?
Your example code shows your FX expression as "%%[fx:h*0,03]". It seems you should replace that comma "," with a decimal point ".". Also, unless you're using that "%%[tjock]" variable somewhere else in the command, you should be able to run it directly where you're using it like "-strokewidth %%[fx:h*0.03]".

Re: Percent escape and strokewidth

Posted: 2017-03-14T14:14:58-07:00
by Videomajk
Thanks, it's always the commas or semicolons that screws up the code ;-). The comma is used in Sweden instead of the decimal point for decimal indication, which I sometimes forgets.
BTW, the parameter is used elsewhere, I just didn't copy the whole code.

Re: Percent escape and strokewidth

Posted: 2017-03-14T14:41:44-07:00
by snibgo
These two commands (Windows CMD syntax) will check the decimal marker:

Code: Select all

magick -size 1000x1000 xc: -set option:tjock %[fx:h*0,03] -format %[tjock] info:
0

magick -size 1000x1000 xc: -set option:tjock %[fx:h*0.03] -format %[tjock] info:
30
I'm in the UK, so the second version with "." (point) works for me.

In some countries, I suppose the first version "," (comma) would work.

"-bordercolor black" is superfluous.

Perhaps you also need "-fill None" so your rectangle is not filled.