php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #50535 Undocumented and unintended? behaviour
Submitted: 2009-12-20 01:03 UTC Modified: 2009-12-21 11:00 UTC
From: bobkellock at gofast dot co dot uk Assigned:
Status: Not a bug Package: GD related
PHP Version: 5.2.12 OS: Win XP SP2
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: bobkellock at gofast dot co dot uk
New email:
PHP Version: OS:

 

 [2009-12-20 01:03 UTC] bobkellock at gofast dot co dot uk
Description:
------------
PHP version is actually 5.2.10 which is what is run on the server at One.com but is due to be upgraded to 5.3 on 2010-01-04.

imagecreatefromjpeg and other imagecreatefromxxx functions put up "Image" in a small rectangle on the centre of the screen.

This is unsightly in my application which simply creates the image and overlays it with some text using imagestring followed by writing the overlaid image to a file. i.e. the original or overlaid image is never written to the screen.

Bob Kellock

Reproduce code:
---------------
   header('Content-Type: image/jpg');
   $serial = "CL1949F";  // normally passed as a session variable
   $img = imagecreatefromjpeg('blankorder.jpg');
   $textcolour = imagecolorallocate($img, 0, 0, 0);
   $font = imageloadfont('Arial24.gdf');
   imagestring($img, $font, 535, 312, $serial, $textcolour);
   imagejpeg($img,'orderform.jpg');
   imagedestroy($img);
   header('refresh: 0; url=stamped.html');  // redirect to new page


Expected result:
----------------
Creation of overlaid file - which works OK.
Screen should be blank. 

Actual result:
--------------
"Image" in a small rectangle is displayed

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2009-12-20 07:03 UTC] rasmus@php.net
Are you sure your image isn't actually broken?  Where would the string, 
"Image" come from?

And why do you think you can emit a header after you have sent the 
image?  

This bug report makes no sense, sorry.
 [2009-12-20 10:23 UTC] bobkellock at gofast dot co dot uk
I object strongly to your comment "This bug report makes no sense".

Just try:

<?php 
   header('Content-type: image/jpeg');
   $img = imagecreatefromjpeg('xxx.jpg');
?>
which generates the spurious display where xxx.jpg is known to be a valid jpeg.

Please note that this is using v5.2.10. I had to give an incorrect version number because the bug reporter would not allow me to submit the report with that number in the Version box and I have no control over the version available from my web host.
 [2009-12-20 13:14 UTC] rasmus@php.net
Try the same thing without the Content-type header and I bet you will 
see an error instead of a broken image.  That error is why it isn't 
working.  There is no bug here.  Those GD functions have worked in PHP 
for 10+ years assuming you have GD support available with JPEG support 
compiled in.
 [2009-12-20 21:08 UTC] scottmac@php.net
Some browsers display the word Image when they can't correct display an image, such as when there is an error :)
 [2009-12-21 11:00 UTC] bobkellock at gofast dot co dot uk
> Try the same thing without the Content-type header and I bet you > > will see an error instead of a broken image.

You lost your bet! There is no error message and it now works exactly as I want i.e. as previously but without the spurious "Image" in a rectangle.

The header line was a lefover fom when I was learning how to use the GD calls and wanted to display the original jpeg; without it what was being displayed was textural gobbledegook.

<?php
  header('Content-type: image/jpeg');
  $img = imagecreatefromjpeg('xxxx.jpg');
  imagejpeg($img);
?>

The above displays the image correctly in Opera 10.10, FF 3.5.6, Safari for Windows 4.0.3, Chrome and IE8.

If I omit the imagejpeg($img) line:
Opera (my default browser) displays the rectangle as previously described.
FF displays the URL of the page.
Chrome and Safari just generate a blank screen.
IE8 displays a red X in a box in the top left of the screen.

Seemingly there is no error but, despite that, it appears that
imagecreatefromjpeg is returning something to the browser which causes some of them to generate a spurious display.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat May 18 23:01:31 2024 UTC