|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #18609 ImageCreateFromJPEG can't fetch from a URL
Submitted: 2002-07-27 12:35 UTC Modified: 2004-05-27 08:33 UTC
Avg. Score:5.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:1 (100.0%)
Same OS:1 (100.0%)
From: midg3t at mail dot com Assigned:
Status: Not a bug Package: Scripting Engine problem
PHP Version: 4.3.0-dev OS: Windows 2000
Private report: No CVE-ID: None
 [2002-07-27 12:35 UTC] midg3t at mail dot com
This bug has been posted once before, but the discussion was closed due to inactivity.

Using GD "1.6.2 or higher" or GD 2 (the versions with PHP 4.2.2), ImageCreateFromJPEG() produces an error when trying to fetch an image from a URL. It works fine for grabbing local files. I am using the PHP SAPI module for Apache 1.3.26.

To generate the error, just use the function


It returns the following error:

Warning: imagecreatefromjpeg: Unable to open '' for reading in c:\folder\file.php on line 53


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2002-07-27 12:36 UTC]
Try this snapshot:
 [2002-07-27 12:37 UTC] midg3t at mail dot com
Just a note that I should have made the two example URLs the same - they were before I edited them.
 [2002-07-27 12:46 UTC]
Try the snapshot..

 [2002-07-27 12:51 UTC] midg3t at mail dot com
The error still occurs.

Version info:
PHP Version 4.3.0-dev
API Versions:
  PHP: 20020307
  PHP Extension: 20020429
  Zend Extension: 20020429
 [2002-07-27 12:54 UTC] midg3t at mail dot com
Using the bundled version of GD2 the error message changed to...

Warning: imagecreatefromjpeg("") - Invalid argument in c:\dir\fakeid.php on line 53
 [2002-08-28 01:00 UTC] php-bugs at lists dot php dot net
No feedback was provided for this bug for over a month, so it is
being suspended automatically. If you are able to provide the
information that was originally requested, please do so and change
the status of the bug back to "Open".
 [2002-08-28 12:24 UTC]
feedback was given..happens also with 4.3.0-dev.

 [2002-08-28 12:25 UTC]
Please add the shortest possible example script
into this report which can be used to reproduce this.
(and set the status back to 'Open' when you do this..)

 [2002-08-29 04:19 UTC] midg3t at mail dot com
 [2002-08-29 12:14 UTC]
Attempt to open a remote image via imagecreatefromjpeg() results in a 'failed to create stream: invalid argument' error.
Opening the same url with fopen() works properly.
 [2002-08-29 13:42 UTC]
I could not verify this (on Linux):

[derick@kossu derick]$ php -v
PHP 4.3.0-dev (cli), Copyright (c) 1997-2002 The PHP Group
Zend Engine v1.3.0, Copyright (c) 1998-2002 Zend Technologies

[derick@kossu derick]$ php > foo.png
$f = imagecreatefromjpeg("");

[derick@kossu derick]$ file foo.png
foo.png: PNG image data, 342 x 435, 8-bit colormap, non-interlaced

 [2002-09-25 09:38 UTC]
streams related...
 [2002-09-25 11:31 UTC]
Please try using this CVS snapshot:
For Windows:

The problem is that the GD extension explicitly disables URL access under windows (it uses the IGNORE_URL_WIN flag when opening the stream).
Yesterday, I enabled this functionality along with include/require for remote files.

Please try a snapshot and let us know how you get on.
 [2002-10-08 06:57 UTC] midg3t at mail dot com
I downloaded that snapshot, maybe because of an error and maybe just because I don't have very much experience in running a PHP server, I got this error on starting Apache...

(null)(): Unable to load dynamic library 'C:\Program Files\PHP\extensions/php_gd.dll' - The specified procedure could not be found.

The php_gd.dll file is in the extensions directory, so I think it may have to do with there being a forwardslash instead of backslash. The extensions directory is configured correctly in my php.ini file.

extension_dir = "C:\Program Files\PHP\extensions"

I apologise if I have made an oversight.
 [2002-10-08 08:23 UTC]
Did you remember to replace ALL the existing PHP related dlls with the ones found in the snapshot package?

php4ts.dll and all the extensions and their extra dlls.

 [2002-10-09 03:54 UTC] midg3t at mail dot com
Thanks for your help, all works fine now.

If it isn't too much trouble to ask, why would the IGNORE_URL_WIN flag have been used in the past?
 [2002-10-09 04:02 UTC]
PHP 4.3.0 comes with a rewritten filemanagement system (Streams) which doesn't rely on features that windows didn't implement.

 [2004-05-26 19:45 UTC] webmaster at 1zb dot de
there must be an unreported change because the images get very dark.
 [2004-05-26 19:49 UTC]

'images get very dark' is not very usefull.

Can you provide a link to these images and a simple script to load them? (aka imagefromjpeg(); and save them). Getting "dark" image has nothing to do with the load from URL problem, imho.

 [2004-05-27 08:33 UTC]
Right, it has nothing to do with this problem, so don't use this bugreport for it. File a new one.
PHP Copyright © 2001-2023 The PHP Group
All rights reserved.
Last updated: Fri Sep 22 08:01:24 2023 UTC