php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #28761 thick line endings drawn with imageline() are ugly
Submitted: 2004-06-13 06:13 UTC Modified: 2021-08-25 11:50 UTC
From: odarcan at hotmail dot com Assigned: cmb (profile)
Status: Closed Package: GD related
PHP Version: Irrelevant OS: Irrelevant
Private report: No CVE-ID: None
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
MUST BE VALID
Solve the problem:
43 - 24 = ?
Subscribe to this entry?

 
 [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?

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2004-06-13 06:18 UTC] odarcan at hotmail dot com
clarification:
the uglyness appears in the junctions of different lines when the first one's ending coords. is the second one's beginning coords., the drawn lines should be more seamless
 [2015-09-07 17:19 UTC] cmb@php.net
-Summary: lines drawn with imageline() are ugly +Summary: thick line endings drawn with imageline() are ugly -Package: Feature/Change Request +Package: GD related
 [2015-09-07 17:19 UTC] cmb@php.net
I agree that this should be improved. Furthermore being able to
choose the desired line-caps ("butt", "round", "square") would be
nice.
 [2015-09-07 22:05 UTC] yohgaki@php.net
-Operating System: win xp +Operating System: Irrelevant
 [2015-09-07 22:05 UTC] yohgaki@php.net
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);
?>
 [2017-01-22 23:00 UTC] cmb@php.net
-Status: Open +Status: Suspended
 [2017-01-22 23:00 UTC] cmb@php.net
Actually, this is a general libgd issue, so I've forwarded to
<https://github.com/libgd/libgd/issues/371>, and suspend this
ticket in the meantime.
 [2021-08-25 11:50 UTC] cmb@php.net
-Status: Suspended +Status: Closed -Assigned To: +Assigned To: cmb
 [2021-08-25 11:50 UTC] cmb@php.net
The upstream ticket has been closed, so I'm closing this ticket as
well.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Mar 28 17:01:29 2024 UTC