pixel exact drawing and png

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
gubach
Posts: 37
Joined: 2013-12-13T11:13:29-07:00
Authentication code: 6789

pixel exact drawing and png

Post by gubach » 2017-12-20T14:22:33-07:00

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!

snibgo
Posts: 10356
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: pixel exact drawing and png

Post by snibgo » 2017-12-20T14:37:54-07:00

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

gubach
Posts: 37
Joined: 2013-12-13T11:13:29-07:00
Authentication code: 6789

Re: pixel exact drawing and png

Post by gubach » 2017-12-21T05:17:51-07:00

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.

snibgo
Posts: 10356
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: pixel exact drawing and png

Post by snibgo » 2017-12-21T05:30:36-07:00

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

gubach
Posts: 37
Joined: 2013-12-13T11:13:29-07:00
Authentication code: 6789

Re: pixel exact drawing and png

Post by gubach » 2017-12-21T06:27:59-07:00

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.

Post Reply