inner Border of an polyline
inner Border of an polyline
Hi eveybody,
I am trying to create a polygon, where i can change the thickness of the border inside the polygon.
The problem is by changing the strokewidth my actual polygon becomes larger, because the stroke becomes larger on both sides of its centerline.
-fill white -stroke blue -strokewidth 10 -draw "polyline 50,50 150,150 150,100 130,50 50,50" this does not work.
I would be plaesed if anyone could give me hint to solve my problem.
I am trying to create a polygon, where i can change the thickness of the border inside the polygon.
The problem is by changing the strokewidth my actual polygon becomes larger, because the stroke becomes larger on both sides of its centerline.
-fill white -stroke blue -strokewidth 10 -draw "polyline 50,50 150,150 150,100 130,50 50,50" this does not work.
I would be plaesed if anyone could give me hint to solve my problem.
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: inner Border of an polyline
This topic was moved from Consulting to Users forum, since Consulting is for Paid consulting.
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: inner Border of an polyline
Here is a comparison of no strokewidth to one that is filled inward. You can adapt to your exact command line since you did not provide it. I use -morphology edgin to create a new thick line inside the polygon and composite it with the original simple line. See http://www.imagemagick.org/Usage/morphology/#edgein


Code: Select all
convert -size 250x250 xc:gray -fill white -stroke red +antialias -draw "polyline 50,50 150,150 150,100 130,50 50,50" tmp1.png

Code: Select all
convert -size 250x250 xc:gray -fill white -stroke red +antialias -draw "polyline 50,50 150,150 150,100 130,50 50,50" \
\( -clone 0 -fill black +opaque white -morphology edgein octagon:8 \) \
\( -clone 0 -fill red -colorize 100 \) \
+swap -compose over -composite tmp2.png

Re: inner Border of an polyline
Thank you very much. Your solution looks good. I am going to check it out.
Re: inner Border of an polyline
@fmw42
Hi your answer seems to work well. I am doing my coding on a PHP server and my admin only provides IM Version 6.2.8.
Is there a workaround without using -morphology and predefinded kernels?
Thank you
Hi your answer seems to work well. I am doing my coding on a PHP server and my admin only provides IM Version 6.2.8.
Is there a workaround without using -morphology and predefinded kernels?
Thank you
-
- Posts: 12159
- Joined: 2010-01-23T23:01:33-07:00
- Authentication code: 1151
- Location: England, UK
Re: inner Border of an polyline
Windows BAT syntax:
(Untested on such a pre-historic version of IM.)
Code: Select all
convert ^
-size 200x200 xc:gray ^
( xc:gray ^
-fill white -stroke blue -strokewidth 10 ^
-draw "polyline 50,50 150,150 150,100 130,50 50,50" ) ^
( xc:Black ^
-fill White -stroke None -strokewidth 10 ^
-draw "polyline 50,50 150,150 150,100 130,50 50,50" ) ^
-composite ^
p2.png
snibgo's IM pages: im.snibgo.com
Re: inner Border of an polyline
you are right.
I will forward your comment to my admin.
your script doesn't do what i ment. But it gave's me a good hint do solve my problem by subtraction or something like this.
Thanks a lot
Matthias
I will forward your comment to my admin.
your script doesn't do what i ment. But it gave's me a good hint do solve my problem by subtraction or something like this.
Thanks a lot
Matthias
-
- Posts: 12159
- Joined: 2010-01-23T23:01:33-07:00
- Authentication code: 1151
- Location: England, UK
Re: inner Border of an polyline
My second "-strokewidth" should be 1, not 10, though this makes no difference to the result.
My command composes with 3 images, so the third is a mask. It is black where pixels should come from the first image (the gray rectangle) and white where pixels should come from the second image (polygon with thick blue strokes). Because the third polygon isn't stroked, we hide the thickening that is outside the polygon.
The ChangeLog only goes back to v6.3.1-6, released in January 2007.
My command composes with 3 images, so the third is a mask. It is black where pixels should come from the first image (the gray rectangle) and white where pixels should come from the second image (polygon with thick blue strokes). Because the third polygon isn't stroked, we hide the thickening that is outside the polygon.
The ChangeLog only goes back to v6.3.1-6, released in January 2007.
snibgo's IM pages: im.snibgo.com
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: inner Border of an polyline
IM 6.2.8 is ancient (over 600 versions old). -morphology edgin is much more current (6.5.9.3) and there was nothing like that command at 6.2.8. Best to use snibgo's solution