Page 1 of 1

pixel exact drawing and png

Posted: 2017-12-20T14:22:33-07:00
by gubach
If I am drawing a triangle with

Code: Select all

"C:\Program Files\ImageMagick-6.9.7-Q8\convert.exe" -size 1000x1000 xc:black -fill white -stroke black -strokewidth 2 -draw "polygon  0,0 1000,1000 0,1000" intermed_mask.png
and open the png (in PS) I see an unexpected result: looking at the lower left corner I see on the left side a black and a gray line and on the bottom only a gray line. With -strokewidth 2 I expected on both sides two black lines. If I am using -strokewidth 1 there is at the bottom no black or gray line at all. For such compositing masks I need pixel exact surroundings of polygons so how can I fix this? Thanks!

Re: pixel exact drawing and png

Posted: 2017-12-20T14:37:54-07:00
by snibgo
One of the lines of the triangles is outside the image. When an image is 1000x1000 pixels, the bottom-right pixel is at 999,999.

Re: pixel exact drawing and png

Posted: 2017-12-21T05:17:51-07:00
by gubach
So I think it is better to forget the stroke command and adapt the coordinates to simulate a kind of shrinking or pushing them away from the image edges.
For a strokewidth=1 this would be 1,1 999,999 1,999. But how can this adaption be made for arbitrary polygons? Ad hoc I would dissect the
image in four quadrants and make a distinction of cases to add/subtract the strokewidth like (x+s, y-s) for the lower-left quadrant.

Re: pixel exact drawing and png

Posted: 2017-12-21T05:30:36-07:00
by snibgo
I don't know what you are trying to do, so I don't know if you need a stroke. If you have a stroke, I suggest you experiment with the stroke colour different to the fill and the background. Then you can see it.

Normally, all polygon vertices should be in the range 0 to 999. If a vertex is outside the image, the polygon will be clipped.

Re: pixel exact drawing and png

Posted: 2017-12-21T06:27:59-07:00
by gubach
I need a black hull/shell around a white polygon with a specified thickness. If those polygons are composed together with no overlap this simulates a controlled gap artifact (see https://www.flickr.com/photos/gbachelier/27419431099) that can be used as a mask to correct such kind of artifacts in a color composing.