php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #62632 Incorrect image generated
Submitted: 2012-07-22 15:17 UTC Modified: 2013-02-21 08:13 UTC
From: marc at phpmyadmin dot net Assigned:
Status: Not a bug Package: GD related
PHP Version: 5.4.5 OS: Linux
Private report: No CVE-ID: None
View Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
If you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: marc at phpmyadmin dot net
New email:
PHP Version: OS:

 

 [2012-07-22 15:17 UTC] marc at phpmyadmin dot net
Description:
------------
The test script (master.html calling image.php) works fine with PHP 5.3.13 but fails to produce an image with PHP 5.4.4 or 5.4.5.

'./configure' '--with-apxs2=/usr/local/apache2/bin/apxs' '--with-libdir=lib64' '--disable-debug' '--enable-calendar' '--with-gd=shared' '--with-freetype-dir' '--with-mysql=shared,mysqlnd' '--with-mysqli=shared,mysqlnd' '--with-regex=php' '--with-png-dir=/usr/lib' '--with-zlib=shared' '--with-iconv=shared' '--enable-ftp' '--with-mcrypt=shared' '--with-bz2=shared' '--enable-zip' '--with-jpeg-dir=/usr/lib' '--enable-mbstring' '--without-sqlite' '--enable-dom' '--enable-json' '--with-pdo-mysql=mysqlnd' '--with-pear' '--enable-bcmath' '--with-curl=shared' '--with-ldap=shared,/usr' '--with-gettext=shared' '--with-snmp=shared' '--enable-soap' '--enable-sockets' 

Test script:
---------------
master.html:
<html>
<head></head>
<body>
<img border="0" alt="the photo should be here" src="image.php" />
</body>
</html>

image.php:
<?php
$contents = file_get_contents('marc.jpg');
header('Content-Type: image/JPEG');
header('Content-Transfer-Encoding: binary');

$srcImage = imagecreatefromstring($contents);
ImageJPEG($srcImage, '', 75);
?>


Expected result:
----------------
A photo is displayed.

Actual result:
--------------
The alt tag of the photo is displayed.

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2012-07-22 19:18 UTC] ab@php.net
$contents = file_get_contents('marc.jpg');

A link to marc.jpg would be useful.
 [2012-07-22 20:52 UTC] marc at phpmyadmin dot net
Here is the image I used:
http://www.infomarc.info/MarcDelisle-140x185.jpg
 [2012-09-15 05:27 UTC] david at nnucomputerwhiz dot com
Works for me in php 5.4.4-4 from Debian testing.
 [2013-02-18 13:00 UTC] kalle@php.net
-Status: Open +Status: Feedback
 [2013-02-18 13:00 UTC] kalle@php.net
have you tried to call the script like:

<?php
$contents = file_get_contents('marc.jpg');

$srcImage = imagecreatefromstring($contents);
ImageJPEG($srcImage, '', 75);
?>

And see if PHP errors out? If headers are sent its often hidden by browsers. Simply go to image.php directly and see if you either get a lot of 'binary' text or an actual PHP error.
 [2013-02-18 17:26 UTC] marc at phpmyadmin dot net
The solution is to use null as the second parameter of ImageJPEG(). In PHP 5.3.13, using '' worked.
 [2013-02-18 17:26 UTC] marc at phpmyadmin dot net
-Status: Feedback +Status: Open
 [2013-02-21 08:13 UTC] pajoye@php.net
-Status: Open +Status: Not a bug
 [2013-02-21 08:13 UTC] pajoye@php.net
.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sun Dec 22 10:01:28 2024 UTC