php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #64614 imagettbbox() Always returns -1 for X coordinate left corner.
Submitted: 2013-04-09 12:11 UTC Modified: 2016-09-24 14:08 UTC
Votes:1
Avg. Score:5.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:0 (0.0%)
Same OS:1 (100.0%)
From: fredcm at gmail dot com Assigned: cmb (profile)
Status: Duplicate Package: GD related
PHP Version: 5.4.13 OS: Linux/Windows
Private report: No CVE-ID: None
 [2013-04-09 12:11 UTC] fredcm at gmail dot com
Description:
------------
//The function imagettbbox() always returns -1 for X coordinate left corner.

$bbox = imagettfbbox(20, 0, './arial.ttf', 'TestImagettfbbox');

echo $bbox[0]; // always -1 - lower left corner, X position
echo $bbox[6]; // always -1 - upper left corner, X position


//with this problem there is no way to align left the text in the image.

Test script:
---------------
$bbox = imagettfbbox(20, 0, './arial.ttf', 'TestImagettfbbox');

echo $bbox[0]; // always -1 - lower left corner, X position
echo $bbox[6]; // always -1 - upper left corner, X position


Expected result:
----------------
Return valid values for X coordinates.
I've tested the imagettbbox() in PHP 5.0.4 and the function is working.


Actual result:
--------------
imagettbbox() always returns -1 for X coordinate of the left corners.

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2015-05-17 16:17 UTC] davehampson12 at gmail dot com
Same reason as the original reporter - I need to calculate the bounding box dimensions of text and this bug doesn't help :)
 [2016-03-31 11:37 UTC] mplomer at gmx dot de
For proposed fix and further info/discussion, see bug #53504
 [2016-09-14 17:36 UTC] cmb@php.net
Besides Mark's fix, I've noticed that external libgd's results may
differ from those of the bundled libgd, see
<https://github.com/libgd/libgd/issues/301>.
 [2016-09-23 12:54 UTC] cmb@php.net
-Status: Open +Status: Closed -Assigned To: +Assigned To: cmb
 [2016-09-23 13:03 UTC] cmb@php.net
-Status: Closed +Status: Duplicate
 [2016-09-23 13:03 UTC] cmb@php.net
Actually, this is a duplicate of bug #53504.
 [2016-09-23 19:03 UTC] davehampson12 at gmail dot com
Thanks guys - much appriciated
 [2016-09-23 20:39 UTC] fredcm at gmail dot com
Thank you so much guys.

You are doing a great job for the humanity.

Fred
 [2016-09-24 13:38 UTC] fredcm at gmail dot com
Guys,
In which PHP release version this fix will be available?
 [2016-09-24 14:08 UTC] cmb@php.net
The fix is scheduled for PHP 5.6.27, 7.0.12 and 7.1.0RC3. Note
that there may still be minor differences when an external libgd
is used instead of the bundled one.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Nov 07 05:01:28 2024 UTC