Percent escape and strokewidth

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
Videomajk
Posts: 14
Joined: 2017-02-18T07:46:04-07:00
Authentication code: 1151

Percent escape and strokewidth

Post 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?
------------------------------------------------------------------------
Imagemagick v 7.0.4 | Windows 10
User avatar
GeeMack
Posts: 718
Joined: 2015-12-01T22:09:46-07:00
Authentication code: 1151
Location: Central Illinois, USA

Re: Percent escape and strokewidth

Post 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]".
Videomajk
Posts: 14
Joined: 2017-02-18T07:46:04-07:00
Authentication code: 1151

Re: Percent escape and strokewidth

Post 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.
------------------------------------------------------------------------
Imagemagick v 7.0.4 | Windows 10
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Percent escape and strokewidth

Post 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.
snibgo's IM pages: im.snibgo.com
Post Reply