i have a simple test code
imagecreatefromjpeg("http://www.eventmag.ru/uploads/users/483/11483/event/logo/14632/5ee58096b7238c30.jpg");
but it cant working
gd-jpeg: JPEG library reports unrecoverable error: Not a JPEG file: starts with 0x89 0x50
PHP Warning: imagecreatefromjpeg(): 'http://www.eventmag.ru/uploads/users/483/11483/event/logo/14632/5ee58096b7238c30.jpg' is not a valid JPEG file in /var/www/site/releases/test.php on line 5
what a problem? PHP 5.4.4-14
gd
GD Support => enabled
GD Version => 2.0
FreeType Support => enabled
FreeType Linkage => with freetype
FreeType Version => 2.4.9
GIF Read Support => enabled
GIF Create Support => enabled
JPEG Support => enabled
libJPEG Version => unknown
PNG Support => enabled
libPNG Version => 1.2.49
WBMP Support => enabled
Directive => Local Value => Master Value
gd.jpeg_ignore_warning => 0 => 0
gettext
GetText Support => enabled
i execute script by the php cli.
The image you're trying to download is actually a PNG, not a JPEG.
Yes, I know the URL ends in .jpg
but that doesn't mean it is actually a JPEG image.
imagecreatefromstring()
is able to automatically detect supported image types from their header. So you should be able to do something like this:
$image_data = file_get_contents('http://www.example.com/image.jpg_or_png_or_whatever');
$img = imagecreatefromstring($image_data);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With