| 
        php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login | 
  [2004-06-13 06:13 UTC] odarcan at hotmail dot com
 Description:
------------
i dont think this is a bug, it may be, and i dont know if reporting this here will do any good,
when drawing lines in gd, other than 90degree angles; the endings of the lines always become horisontal
and it looks really, REALLY cheap! it doesnt show when the lines are 1 pixel wide but when drawing thicker lines, it becomes VERY obvious, this is my greatest obstacle in my project right now, ive emailed boutell.com but got no answer.
thanks,
Osman Darcan
Reproduce code:
---------------
<?
$im = imagecreate(400, 400) or die ("Cannot Initialize new GD image stream");
header ("Content-type: image/png");
$grey = imagecolorallocate ($im, 155, 155, 155);
$blue = imagecolorallocate ($im, 0, 0, 255);
$green = imagecolorallocate ($im, 0, 155, 0);
imagesetthickness($im,9);
imageline($im,5,5,50,50,$blue);
imageline($im,50,50,100,300,$blue);
imageline($im,100,300,300,40,$blue);
imageline($im,5+20,5+20,50+20,50+20,$green);
imageline($im,50+20,50+20,60+20,300+20,$green);
imageline($im,100+20,300+20,300+20,40+20,$green);
imagepng($im,"",60);
?>
Expected result:
----------------
try different values for imagesetthickness
Actual result:
--------------
you'll see that some lines look very weird..  im not sure its a bug but it's sure ugly allright..
php and gd deserves something as simple as a decent option to set thickness to lines.. shouldnt be so hard to implement?
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits             
             | 
    |||||||||||||||||||||||||||
            
                 
                Copyright © 2001-2025 The PHP GroupAll rights reserved.  | 
        Last updated: Tue Nov 04 03:00:01 2025 UTC | 
I agree that this should be improved. Furthermore being able to choose the desired line-caps ("butt", "round", "square") would be nice.Modified script to make it work with PHP 5.6/7.0 <?php $im = imagecreate(400, 400) or die ("Cannot Initialize new GD image stream"); header ("Content-type: image/png"); $grey = imagecolorallocate ($im, 155, 155, 155); $blue = imagecolorallocate ($im, 0, 0, 255); $green = imagecolorallocate ($im, 0, 155, 0); imagesetthickness($im,9); imageline($im,5,5,50,50,$blue); imageline($im,50,50,100,300,$blue); imageline($im,100,300,300,40,$blue); imageline($im,5+20,5+20,50+20,50+20,$green); imageline($im,50+20,50+20,60+20,300+20,$green); imageline($im,100+20,300+20,300+20,40+20,$green); imagepng($im,NULL,9); ?>