php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #63814 angles parameters in imagefilledarc are integers, they should be float
Submitted: 2012-12-20 12:32 UTC Modified: 2013-01-02 09:19 UTC
From: webmaster at fxtop dot com Assigned:
Status: Wont fix Package: GD related
PHP Version: 5.4.9 OS: Windows
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: webmaster at fxtop dot com
New email:
PHP Version: OS:

 

 [2012-12-20 12:32 UTC] webmaster at fxtop dot com
Description:
------------
see sample result at
http://mon-convertisseur.fr/php/imgangle.php?DEGRE=172.3

angles are truncated to nearest integer, in imagefilledarc function, they shouldn't

you can change parameter if you like

---
From manual page: http://www.php.net/function.imagefilledarc#refsect1-function.imagefilledarc-description
---



Test script:
---------------
header("Content-type: image/jpeg");

if (isset($_GET["DEGRE"])){ $lDegre=$_GET["DEGRE"];}
$lSizeX=916;
$lSizeY=945;
$image  = imagecreatetruecolor($lSizeX, $lSizeY);
$colorGreen = imagecolorallocate($image, 0, 255, 0);
		
// background coming from http://commons.wikimedia.org/wiki/File:Protractor_katomierz.jpg with some little changes
$fond=imagecreatefromjpeg("Protractor_katomierz_tourne05b.jpg");

//HERE I ROUND DEGRE PARAMETER BECAUSE imagefilledarc only accept integers (I prefer it rounded than truncated)
$lNumDegre=round($lDegre);
$lResult|=imagefilledarc ($image , 460 , 474 , 2*430 , 2*430  , -$lNumDegre , 0, $colorGreen , IMG_ARC_PIE );
$lResult|=imagecopymerge($image, $fond, 0, 0, 0 , 0, $lSizeX,$lSizeY,75);
imagejpeg($image, "temp.jpg");
imagedestroy($image);
echo file_get_contents("temp.jpg");

Expected result:
----------------
imagefilledarc should accept float parameters for "start" and "end" parameters.
As you can see on sample at http://mon-convertisseur.fr/php/imgangle.php?DEGRE=172.3 green backgound allways fall on a degre graduation  of the protactor. 



Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2012-12-20 15:24 UTC] remi@php.net
the gd extension is mostly a wrapper for gd library.

As gd library doesn't accept float values for this comment, I think this is not possible.
 [2012-12-28 10:57 UTC] ab@php.net
-Status: Open +Status: Wont fix
 [2012-12-28 10:57 UTC] ab@php.net
That's right, gd takes only integers for coordinates as they're literally pixels. See here for arcs

http://lxr.php.net/xref/PHP_5_4/ext/gd/libgd/gd.h#546

If you work with float data, you probably will need to do conversion from/to int.
 [2012-12-28 14:12 UTC] webmaster at fxtop dot com
Hello, thanks for your investigation.
I don't blame that coordinates in pixel are integers, that's normal.
The problem is that angles are integers, which is an undue limitation : angles are rounded to nearest degree.  In astronomy, they deal with seconds of arc, which is 1/3600 of a degree. 

If problem is inside an external library, it should be reported to that library.
What is the proper website to report such limitation ?
Regards
 [2013-01-02 09:19 UTC] ab@php.net
Of course you can discuss that on https://bitbucket.org/pierrejoye/gd-libgd , but i don't think it's possible to get around that without using some anti aliasing technics. Also you might want to take a look at the Cairo binding which provides a vector graphics API.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat Dec 21 17:01:58 2024 UTC