php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #40490 imagejpeg() returns page URL instead of image
Submitted: 2007-02-15 02:01 UTC Modified: 2007-02-23 21:00 UTC
From: php at rebby dot com Assigned:
Status: Not a bug Package: GD related
PHP Version: 5.2.1 OS: Slackware Linux
Private report: No CVE-ID: None
 [2007-02-15 02:01 UTC] php at rebby dot com
Description:
------------
A GD page which relies on imagejpeg(), among other functions, returns the page URL rather than displaying the image. This script has worked fine since early 4.x when it was developed. No errors of any kind are output in my error log.

Reproduce code:
---------------
http://rebby.com/images/email/image.txt

Expected result:
----------------
The code above is included after loading a global configuration file. The code pulls the location of a jpeg image on my filesystem, makes some alterations (resizes the image and adds a URL tag), and should output the image directly to the browser.

Actual result:
--------------
Instead of returning the image the URL of the image is returned instead. For example, if you source this page at http://rebby.com/image.php?i=123&s=4 the string "http://rebby.com/image.php?i=123&s=4" is displayed in the browser instead of the desired image.

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2007-02-15 08:58 UTC] tony2001@php.net
Sorry, but your problem does not imply a bug in PHP itself.  For a
list of more appropriate places to ask for help using PHP, please
visit http://www.php.net/support.php as this bug system is not the
appropriate forum for asking support questions.  Due to the volume
of reports we can not explain in detail here why your report is not
a bug.  The support channels will be able to provide an explanation
for you.

Thank you for your interest in PHP.


 [2007-02-15 13:59 UTC] php at rebby dot com
Thank you for your assistance. I guess that I will just have to spend a bit more time troubleshooting to figure out why this script broke between 5.2.0 and 5.2.1.
 [2007-02-15 14:55 UTC] pajoye@php.net
I cannot access your script (404).

But some tips:
- verify you don't add whitespaces before or after your <? ?> tags
- you don't echo something
- the right header has been sent

But nothing change in image[format] between 5.2.0 and 5.2.1.  Ask on php-general if you fail to find the problem.

 [2007-02-15 15:38 UTC] php at rebby dot com
Since the status was changed to "Bogus" and it was determined that this was not a bug, I removed the code from my site this morning. Because this is still being looked at, I restored the code in question to http://rebby.com/images/email/image.txt

I will return my development system to 5.2.1 and continue to debug the problem.
 [2007-02-23 21:00 UTC] php at rebby dot com
I found the problem. My issue was due to the removal of --enable-memory-limit (From the changelog: "memory-limit is always enabled (--enable-memory-limit removed)" combined with my script requirements and my local configuration.

Prior to PHP 5.2.1 I did use the --enable-memory-limit configuration variable however I had experimented with it thus my configuration had the memory_limit set to 8M (I believe that this is/was the default in the recommended configuration. I got this setting from a recommended configuration file in a 4.x release). Since I was not using --enable-memory-limit at compile time, this value was discarded. Now that 5.2.1 uses --enable-memory-limit by default, this value is in full effect.

With memory_limit enabled and set to value that is to small for my requirements, running out of memory causes the script to crash at the imagecreatefromjpeg() call. Unfortunately, since the script crashes hard, no logging is performed to aid in troubleshooting.

This issue has pointed out a bug in the documentation however. On http://www.php.net/manual/en/ini.core.php it is still noted:

<snip>
In order to use this directive you must have enabled it at compile time. So, your configure line would have included: --enable-memory-limit.
</snip>

As of 5.2.1 this is no longer the case since the --enable-memory-limit was removed from the configure script and is now the default.

This little documentation oversight caused me to overlook the issue with the value of memory_limit in my php.ini being to small in my initial troubleshooting.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sun Apr 28 20:01:29 2024 UTC