php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #25678 Issues with imageantialias and imagesetthickness
Submitted: 2003-09-27 07:58 UTC Modified: 2003-09-28 18:57 UTC
From: php-bugs at demark dot org Assigned:
Status: Not a bug Package: GD related
PHP Version: 4.3.3 OS: Redhat 7.3 (2.4.20-20.7)
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: php-bugs at demark dot org
New email:
PHP Version: OS:

 

 [2003-09-27 07:58 UTC] php-bugs at demark dot org
Description:
------------
Neither imageantialias and imagesetthickness seem to work reliably.

The included code produces a significantly different image than one would expect.

Reproduce code:
---------------
<?php

        $im = imagecreatetruecolor(500,500);

        $col0 = imagecolorallocate($im,153,204,153);
        $col1 = imagecolorallocate($im,118,153,118);

        imagefilledrectangle($im,0,0,499,499,$col0);

        imageantialias($im,TRUE);
        imagesetthickness($im,5);

        imagepolygon($im,array(100,100,100,400,400,400,400,100),4,$col1);
        imagerectangle($im,150,150,350,350,$col1);
        imageline($im,200,200,200,300,$col1);
        imageline($im,200,300,300,300,$col1);
        imageline($im,300,300,300,200,$col1);
        imageline($im,300,200,200,200,$col1);
        imageellipse($im,250,250,400,400,$col1);

        header("Content-type: image/png");
        imagepng($im);

?>


Expected result:
----------------
This code should generate four figures on a 500 x 500 image. Each figure should be centered on the image.

Figure 1: Small square drawn via imageline
Figure 2: Medium square drawn via imagerectangle
Figure 3: Large square drawn via imagepolygon
Figure 4: Large circle drawn via imageellipse

All figures should be drawn with a 5 pixel thick line.
All figures should be antialiased.

Actual result:
--------------
As listed, the code generates a properly sized image, but none of the figures are antialiased and only the medium square is set to the proper thickness. All the other figures are drawn with a 1 pixel thick line.

This image is available at:
http://www.demark.org/phpgdbug/image.png

If I comment out the imageantialias line, no figures are antialiases (as expected), but only the squares are drawn with the proper thickness. Once again, the circle is drawn with a 1 pixel thick line.

This image is available at:
http://www.demark.org/phpgdbug/image-noaa.png



Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2003-09-28 18:57 UTC] php-bugs at demark dot org
Looks to be a bug in the GD library. I wrote a quick 
program in C to call GD directly and got the same 
results.
 [2013-09-09 08:18 UTC] adolf at sharklasers dot com
After 10 years the problem still exists! :(
A quick workaround would be to draw a second line 1 pixel displaced to the 
original line. You have 2 lines but it looks like one line with 2 pixels 
thickness.
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Fri May 02 10:01:28 2025 UTC