Debian Bug report logs -
#561571
Wrong X-coordinate calculation in imagettfbbox function of php5
Reported by: Максим Качалин <m@lifelink.ru>
Date: Fri, 18 Dec 2009 10:42:01 UTC
Severity: normal
Tags: moreinfo
Found in version php5/5.2.11.dfsg.1-2
Fixed in version 5.2.12.dfsg.1-1
Done: Ondřej Surý <ondrej@sury.org>
Bug is archived. No further changes may be made.
Toggle useless messages
Report forwarded
to debian-bugs-dist@lists.debian.org, Debian PHP Maintainers <pkg-php-maint@lists.alioth.debian.org>:
Bug#561571; Package libapache2-mod-php5.
(Fri, 18 Dec 2009 10:42:04 GMT) (full text, mbox, link).
Acknowledgement sent
to Максим Качалин <m@lifelink.ru>:
New Bug report received and forwarded. Copy sent to Debian PHP Maintainers <pkg-php-maint@lists.alioth.debian.org>.
(Fri, 18 Dec 2009 10:42:04 GMT) (full text, mbox, link).
Message #5 received at submit@bugs.debian.org (full text, mbox, reply):
Package: libapache2-mod-php5
Version: 5.2.11.dfsg.1-2
Package: libgd2-xpm
Version: 2.0.36~rc1~dfsg-3.1
When site being opened first time function imagettfbbox calculates wrong
X-coordinate.
As a result we seen only "And Zend Engine ..." string. If I refresh
site, coordintes calculates correct and I'll see both sign "Powere by
PHP" and "And Zend Optimizer
There is test script:
<?php^M
// Create a 300x150 image^M
$im = imagecreatetruecolor(300, 150);^M
$black = imagecolorallocate($im, 0, 0, 0);^M
$white = imagecolorallocate($im, 255, 255, 255);^M
// Set the background to be white^M
imagefilledrectangle($im, 0, 0, 299, 299, $white);^M
// Path to our font file^M
$font = $_SERVER["DOCUMENT_ROOT"].'/bitrix/modules/main/fonts/font.ttf';^M
// First we create our bounding box for the first text^M
$bbox = imagettfbbox(10, 45, $font, 'Powered by PHP ' . phpversion());^M
// This is our cordinates for X and Y^M
$x = $bbox[0] + (imagesx($im) / 2) - ($bbox[4] / 2) - 25;^M
$y = $bbox[1] + (imagesy($im) / 2) - ($bbox[5] / 2) - 5;^M
var_dump($x);
var_dump($y);
die;
// Write it
imagettftext($im, 10, 45, $x, $y, $black, $font, 'Powered by PHP ' .
phpversion());^M
// Create the next bounding box for the second text^M
$bbox = imagettfbbox(10, 45, $font, 'and Zend Engine ' . zend_version());^M
// Set the cordinates so its next to the first text^M
$x = $bbox[0] + (imagesx($im) / 2) - ($bbox[4] / 2) + 10;^M
$y = $bbox[1] + (imagesy($im) / 2) - ($bbox[5] / 2) - 5;^M
// Write it^M
imagettftext($im, 10, 45, $x, $y, $black, $font, 'and Zend Engine ' .
zend_version());^M
// Output to browser^M
header('Content-type: image/png');^M
imagepng($im);^M
imagedestroy($im);^M
?>
This is a result of var_dump, when firstly opened:
int(1073741950) int(139)
and after site refresh:
float(69.5) int(139)
I'm using Debian 'squeeze':
Linux 2.6.31-1-686 #1 SMP Sun Nov 15 20:39:33 UTC 2009 i686 GNU/Linux
Information forwarded
to debian-bugs-dist@lists.debian.org, Debian PHP Maintainers <pkg-php-maint@lists.alioth.debian.org>:
Bug#561571; Package libapache2-mod-php5.
(Fri, 08 Jan 2010 17:06:03 GMT) (full text, mbox, link).
Acknowledgement sent
to Ondřej Surý <ondrej@sury.org>:
Extra info received and forwarded to list. Copy sent to Debian PHP Maintainers <pkg-php-maint@lists.alioth.debian.org>.
(Fri, 08 Jan 2010 17:06:03 GMT) (full text, mbox, link).
Message #10 received at 561571@bugs.debian.org (full text, mbox, reply):
tag 561571 +moreinfo
thank you
Could you provide font from your test script or confirm I can use any
TTF font from system?
--
Ondřej Surý <ondrej@sury.org>
http://blog.rfc1925.org/
Added tag(s) moreinfo.
Request was from Ondřej Surý <ondrej@sury.org>
to control@bugs.debian.org.
(Fri, 08 Jan 2010 17:06:05 GMT) (full text, mbox, link).
Message sent on
to Максим Качалин <m@lifelink.ru>:
Bug#561571.
(Fri, 08 Jan 2010 17:06:07 GMT) (full text, mbox, link).
Information stored
:
Bug#561571; Package libapache2-mod-php5.
(Mon, 11 Jan 2010 03:54:07 GMT) (full text, mbox, link).
Acknowledgement sent
to Максим Качалин <m@lifelink.ru>:
Extra info received and filed, but not forwarded.
(Mon, 11 Jan 2010 03:54:07 GMT) (full text, mbox, link).
Message #20 received at 561571-quiet@bugs.debian.org (full text, mbox, reply):
[Message part 1 (text/plain, inline)]
Hello.
Font is attached to the letter.
I tried this script on another server with this font, but with another
versions of PHP and GD — all ok.
Maksim Kachalin.
> tag 561571 +moreinfo
> thank you
>
> Could you provide font from your test script or confirm I can use any
> TTF font from system?
>
>
[font.ttf (application/octet-stream, attachment)]
Information stored
:
Bug#561571; Package libapache2-mod-php5.
(Mon, 11 Jan 2010 15:48:13 GMT) (full text, mbox, link).
Acknowledgement sent
to Ondřej Surý <ondrej@sury.org>:
Extra info received and filed, but not forwarded.
(Mon, 11 Jan 2010 15:48:13 GMT) (full text, mbox, link).
Message #25 received at 561571-quiet@bugs.debian.org (full text, mbox, reply):
2010/1/10 Максим Качалин <m@lifelink.ru>:
> Hello.
>
> Font is attached to the letter.
Thanks, I will retest your example script in my environment.
> I tried this script on another server with this font, but with another
> versions of PHP and GD — all ok.
What are versions of PHP5 and GD on that another server? Do you use
testing or unstable?
Ondrej
--
Ondřej Surý <ondrej@sury.org>
http://blog.rfc1925.org/
Reply sent
to Ondřej Surý <ondrej@sury.org>:
You have taken responsibility.
(Mon, 11 Jan 2010 16:18:13 GMT) (full text, mbox, link).
Notification sent
to Максим Качалин <m@lifelink.ru>:
Bug acknowledged by developer.
(Mon, 11 Jan 2010 16:18:13 GMT) (full text, mbox, link).
Message #30 received at 561571-done@bugs.debian.org (full text, mbox, reply):
Version: 5.2.12.dfsg.1-1
So to summarize:
lenny version (5.2.6-1+lenny4) works ok.
testing and unstable versions (5.2.11+) are broken.
I have retested with php 5.2.12.dfsg.1-1 (unstable) and 5.3.1-1
(experimental) and both return consistent results.
5.3.1-1:
root@howl:/tmp# php test.php
int(73)
float(135.5)
root@howl:/tmp# php test.php
int(73)
float(135.5)
5.2.12.dfsg.1-1:
root@howl:/tmp# php test.php
float(69.5)
int(139)
root@howl:/tmp# php test.php
float(69.5)
int(139)
I'm closing the bug as fixed in 5.2.12.dfsg.1-1, feel free to reopen
the bug if your testing (with 5.2.12.dfsg.1-1) differ.
Ondrej
2010/1/11 Максим Качалин <m@lifelink.ru>:
> PHP Version 5.2.6-1+lenny4
>
> Package: php5-gd
> Priority: optional
> Section: web
> Installed-Size: 160
> Maintainer: Debian PHP Maintainers <pkg-php-maint@lists.alioth.debian.org>
> Architecture: i386
> Source: php5
> Version: 5.2.6.dfsg.1-1+lenny3
>
>
>> 2010/1/10 Максим Качалин <m@lifelink.ru>:
>>
>>>
>>> Hello.
>>>
>>> Font is attached to the letter.
>>>
>>
>> Thanks, I will retest your example script in my environment.
>>
>>
>>>
>>> I tried this script on another server with this font, but with another
>>> versions of PHP and GD — all ok.
>>>
>>
>> What are versions of PHP5 and GD on that another server? Do you use
>> testing or unstable?
>>
>> Ondrej
>>
>
>
--
Ondřej Surý <ondrej@sury.org>
http://blog.rfc1925.org/
Bug archived.
Request was from Debbugs Internal Request <owner@bugs.debian.org>
to internal_control@bugs.debian.org.
(Tue, 09 Feb 2010 07:34:49 GMT) (full text, mbox, link).
Send a report that this bug log contains spam.
Debian bug tracking system administrator <owner@bugs.debian.org>.
Last modified:
Sun Jul 2 03:06:52 2023;
Machine Name:
bembo
Debian Bug tracking system
Debbugs is free software and licensed under the terms of the GNU
Public License version 2. The current version can be obtained
from https://bugs.debian.org/debbugs-source/.
Copyright © 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson,
2005-2017 Don Armstrong, and many other contributors.