Draw fill default

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

Draw fill default

Post by rmabry »

From the command line, the following generates a triangle filled with black, so it seems the default is the same as if adding -fill black.

Code: Select all

convert -size 150x100 xc:white -stroke red -strokewidth 4 -draw "polygon 20,20 130,20 130,80" filltest-cmd.png
However, in PerlMagick, the following generates an unfilled triangle, so the default is the same as if adding fill => 'none'.

Code: Select all

#!/usr/bin/perl -- 
use Image::Magick;
my $image = new Image::Magick;
$image->Set(size => '150x100');
$image->Read('xc:white');
$image->Draw(primitive=>'polygon', points=>'20,20 130,20 130,80', 
	stroke=>'red', strokewidth=>4);
$image->Write('filltest-pl.png');
Which is desirable? My own feeling is that the perl version is best - if you want a fill say so, otherwise you don't get one.

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

Post by magick »

Setting fill to opaque by default from the command line is a convenience so commands like:
  • convert label:Magick label.png
produce reasonable results. You can of course override the default with the -fill option:
  • convert -size 150x100 xc:white -fill none -stroke red -strokewidth 4 -draw "polygon 20,20 130,20 130,80" filltest-cmd.png
We do not do this with PerlMagick (or other API's) because program development assumes a greater skill than command line scripting.
Post Reply