strokewidth

Post any defects you find in the released or beta versions of the ImageMagick software here. Include the ImageMagick version, OS, and any command-line required to reproduce the problem. Got a patch for a bug? Post it here.
Post Reply
User avatar
rmabry
Posts: 148
Joined: 2004-04-13T11:25:27-07:00

strokewidth

Post by rmabry »

Here's a nit-picky little thing (I'm using 6.3.1). If you don't specify -stroke on the command line, then setting -strokewidth has no effect and a strokewidth of 1 is produced (in the default stroke color black). So the following produces a black line of strokewidth 1.

Code: Select all

convert logo: -strokewidth 10 -draw "line 30,30 60,30" ...
This seems wrong. Of course, adding -stroke black gives the expected result.

On the other hand, in PerlMagick one can omit the stroke color and get the correct stroke width:

Code: Select all

$image->Draw(strokewidth =>10, primitive => 'line', points => '30,30 60,30')
Rick
User avatar
rmabry
Posts: 148
Joined: 2004-04-13T11:25:27-07:00

Re: strokewidth

Post by rmabry »

rmabry wrote: Here's a nit-picky little thing (I'm using 6.3.1).

Here's something less picky, more complicated.

There seems to be an inconsistency in the type of lines produced with various strokewidths. In the following image, the numbers correspond to the strokewidths set for various Draw/line/strokewidth commands for vertical line segments starting at integer coordinates. The top set of line segments is produced by setting strokewidth, the bottom set are segments whose width matches the number, for comparison. All lines start

Image

(A magnified version is here.)

The results:
  • 0: A strokewidth set to 0 gives a drawn stroke of width 1, so it is as if the strokewidth were set to 1. In my view, a strokewidth explicitly set to zero should give no drawing.

    1, 3, 5, etc: Odd strokewidths are fine.

    2: Anomolously, this produces an antialiased line centered at y+0.5, not a bad result, splitting the difference in this way. But ...

    4, 6, 8, etc: All of these produce segments of widths one greater than the strokewidth (i.e., widths 5, 7, 9, etc.), which seems just plain wrong.
Moreover, the strokewidth of 2 seems to give a rounded cap at the endpoints, while none of the higher widths do this.

I'm stroking out here.

Rick
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Post by magick »

It always a question of default values. By default fill is set to opaque black and stroke is transparent. This was reversed in PerlMagick but for sake of consistency between the command line and PerlMagick was patched recently so both produce the same result. The secret to success is to specify precisely what you want such as -fill none -stroke red -strokewidth 10.
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Post by magick »

We're aware of problems with strokewidth. We have not come up with a solution just yet. You are welcome of course to take a look at magick/drawing.c and fix the problem. Its perplexed us for a number of years now and we wrote the code!
User avatar
rmabry
Posts: 148
Joined: 2004-04-13T11:25:27-07:00

Post by rmabry »

magick wrote: You are welcome of course to take a look at magick/drawing.c and fix the problem.

I looked. I shrank back in horror! Actually, I remember looking at this a long time ago and feeling more brave. It is a heroic undertaking to attempt this. I am no hero.
Its perplexed us for a number of years now and we wrote the code!


I have years of back-perplexedness in other areas I must look to first, but thanks for the kind offer! I wish I did have time for it because I now need an accurate version of the stroke. I'll ponder other solutions meanwhile.

Rick
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Post by anthony »

You can also read all about this in the IM Examples....
Drawing Lines, Line Width and Stroke
http://www.cit.gu.edu.au/~anthony/graph ... trokewidth

The example set above this on some of the weirder stroke effects (at '-strokewidth 0' is also a good read.

what actually happend for lines is they are drawn twice, once with fill and once with stroke.
The fill produces thin lines. the stroke produces a controled thick line, weird but it is versitle and it works.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
Post Reply