Antialias problem with Draw()

PerlMagick is an object-oriented Perl interface to ImageMagick. Use this forum to discuss, make suggestions about, or report bugs concerning PerlMagick.
Post Reply
erinspice

Antialias problem with Draw()

Post by erinspice »

Hi! I have a script with the following lines of code:

Code: Select all

$color = "#ff0000";

my $x = $image->Draw(fill=>'#000000',primitive=>'rectangle',points=>"0,0 $width,$height",antialias=>0);
$x && warn $x;

$x = $image->Draw(fill=>'#ffffff',primitive=>'rectangle',points=>"1,$whitestart $greywidth, $greyheight", antialias=>0);
$x && warn $x;

$greyheight -= $barheight;
$x = $image->Draw(fill=>'#eeeeee', primitive=>'rectangle',points=>"1,1 $greywidth,$barheight",antialias=>0);
$x && warn $x;

$x = $image->Draw(fill=>$color, primitive=>'rectangle',points=>"1,1 $barwidth,$barheight",antialias=>0);
$x && warn $x;
My problem is that fourth and last [red] rectangle that is coming out antialiased with lots of shading on the edges, which isn't what I want. I can only think of 2 differences between the fourth call to Draw() and the first three: the fourth one uses a user-specified color and also, it draws on top of 2 other rectangles, where the others draw on 0 and 1 rectangle, respectively. Any suggestions?

Image
erinspice

Re: Antialias problem with Draw()

Post by erinspice »

Wow, this forum isn't very active, is it. :( Anyway, I figured the problem out. It wasn't an antialiasing problem. The JPEG compression was causing the artifacts. I started saving the files as GIFs and the problem was fixed.
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: Antialias problem with Draw()

Post by anthony »

GIF may not have edging artifacts but if the number of colors in the image exceeds 256 you will get color reduction happening. Use PNG, or for intermedte processing image use MIFF or even .miff.gz (gziped miff).
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
Post Reply