Page 1 of 1

inner Border of an polyline

Posted: 2014-07-09T08:38:28-07:00
by OE-MS1
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.

Re: inner Border of an polyline

Posted: 2014-07-09T10:20:14-07:00
by fmw42
This topic was moved from Consulting to Users forum, since Consulting is for Paid consulting.

Re: inner Border of an polyline

Posted: 2014-07-09T10:30:45-07:00
by fmw42
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
Image

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
Image

Re: inner Border of an polyline

Posted: 2014-07-09T12:10:54-07:00
by OE-MS1
Thank you very much. Your solution looks good. I am going to check it out.

Re: inner Border of an polyline

Posted: 2014-07-10T23:53:11-07:00
by OE-MS1
@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

Re: inner Border of an polyline

Posted: 2014-07-11T05:53:19-07:00
by snibgo
Windows BAT syntax:

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
(Untested on such a pre-historic version of IM.)

Re: inner Border of an polyline

Posted: 2014-07-11T06:14:50-07:00
by OE-MS1
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

Re: inner Border of an polyline

Posted: 2014-07-11T06:43:12-07:00
by snibgo
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.

Re: inner Border of an polyline

Posted: 2014-07-11T09:06:12-07:00
by fmw42
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

Re: inner Border of an polyline

Posted: 2014-07-11T09:07:33-07:00
by OE-MS1
thx