|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2016-08-12 04:45 UTC] php dot bohwaz at miam dot kd2 dot org
Description:
------------
I am using PHP to extract thumbnails from JPEG files, and this used to work fine, but I upgraded to PHP 5.6 (from 5.4) and now it seems that exif_* functions are unable to find thumbnail data in every JPEG file I'm trying.
Works:
$ php -v && php -r 'var_dump(strlen(exif_thumbnail("http://www.exiv2.org/include/img_1771.jpg")));'
PHP 5.4.45-0+deb7u4 (cli) (built: Jun 29 2016 14:51:18)
Copyright (c) 1997-2014 The PHP Group
Zend Engine v2.4.0, Copyright (c) 1998-2014 Zend Technologies
int(5448)
Doesn't work:
$ php -v && php -r 'var_dump(strlen(exif_thumbnail("http://www.exiv2.org/include/img_1771.jpg")));'
PHP 5.6.24-0+deb8u1 (cli) (built: Jul 26 2016 08:17:07)
Copyright (c) 1997-2016 The PHP Group
Zend Engine v2.6.0, Copyright (c) 1998-2016 Zend Technologies
with Zend OPcache v7.0.6-dev, Copyright (c) 1999-2016, by Zend Technologies
PHP Warning: exif_thumbnail(img_1771.jpg): IFD data bad offset: 0xFFFFFC52 length 0x01C2 in Command line code on line 1
Warning: exif_thumbnail(img_1771.jpg): IFD data bad offset: 0xFFFFFC52 length 0x01C2 in Command line code on line 1
int(0)
Same result with exif_read_image_data(), the THUMBNAIL section is never populated.
Other examples from other cameras:
http://bohwaz.net/photos/2014/02-fevrier/p20140219_193908.jpg (Panasonic Lumix GF5)
http://bohwaz.net/photos/2014/01-janvier/p20140117_080901.jpg (Nokia E7 phone)
http://bohwaz.net/photos/2014/01-janvier/12-Val_Suzon/p20140112_140758.jpg (Fujifilm HS20 EXR)
Test script:
---------------
var_dump(strlen(exif_thumbnail("http://www.exiv2.org/include/img_1771.jpg")));
Expected result:
----------------
int(5448)
Actual result:
--------------
PHP Warning: exif_thumbnail(img_1771.jpg): IFD data bad offset: 0xFFFFFC52 length 0x01C2 in Command line code on line 1
Warning: exif_thumbnail(img_1771.jpg): IFD data bad offset: 0xFFFFFC52 length 0x01C2 in Command line code on line 1
int(0)
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Fri Oct 24 16:00:02 2025 UTC |
(Continued, as antispam forbids me from posting too many URLs) with different errors, or sometimes no error, but still no thumbnail: $ php -r 'var_dump(strlen(exif_thumbnail("http://bohwaz.net/photos/2014/02-fevrier/p20140219_193908.jpg")));' int(0) $ php -r 'var_dump(strlen(exif_thumbnail("http://bohwaz.net/photos/2014/01-janvier/p20140117_080901.jpg")));' int(0) $ php -r 'var_dump(strlen(exif_thumbnail("http://bohwaz.net/photos/2014/01-janvier/12-Val_Suzon/p20140112_140758.jpg")));' PHP Warning: exif_thumbnail(p20140112_140758.jpg): corrupt EXIF header: maximum directory nesting level reached in Command line code on line 1 Warning: exif_thumbnail(p20140112_140758.jpg): corrupt EXIF header: maximum directory nesting level reached in Command line code on line 1 int(0)It was working on a 5.x release also... then it stopped after an Ubuntu update ... so I decided to go to v7 and Ubuntu 16.04 thinking the bug would be fixed... but apparently not.. or I am missing some other dependency. ...source... $file='IMG_4741.JPG'; $image = exif_thumbnail($file, $width, $height, $type); echo "length is :" . strlen($image); ... output and error message ... PHP Warning: exif_thumbnail(IMG_4741.JPG): IFD data bad offset: 0xFFFFFCF2 length 0x0ED8 in .../example1.php on line 3 length is :0 ... ... php -v ... PHP 7.0.8-0ubuntu0.16.04.2 (cli) ( NTS ) Copyright (c) 1997-2016 The PHP Group Zend Engine v3.0.0, Copyright (c) 1998-2016 Zend Technologies with Zend OPcache v7.0.8-0ubuntu0.16.04.2, Copyright (c) 1999-2016, by Zend Technologies ... uname -a ... Linux ... 4.4.0-34-generic #53-Ubuntu SMP Wed Jul 27 16:06:28 UTC 2016 i686 i686 i686 GNU/Linuxphp -v && php -r 'var_dump(strlen(exif_thumbnail("http://www.exiv2.org/include/img_1771.jpg")));' PHP 5.4.45-0+deb7u5 (cli) (built: Aug 30 2016 20:15:34) Copyright (c) 1997-2014 The PHP Group Zend Engine v2.4.0, Copyright (c) 1998-2014 Zend Technologies PHP Warning: exif_thumbnail(img_1771.jpg): IFD data bad offset: 0xFFFFFC52 length 0x01C2 in Command line code on line 1 int(0)Same issue on Mac OS X 10.9.5 on PHP 5.6.29. I'm sure it's been around for about as long. PHP installed via MacPorts. $ php -v && php -r 'var_dump(strlen(exif_thumbnail("http://www.exiv2.org/include/img_1771.jpg")));' PHP 5.6.29 (cli) (built: Dec 10 2016 15:52:37) Copyright (c) 1997-2016 The PHP Group Zend Engine v2.6.0, Copyright (c) 1998-2016 Zend Technologies Warning: exif_thumbnail(img_1771.jpg): IFD data bad offset: 0xFFFFFC52 length 0x01C2 in Command line code on line 1 int(0)Same for PHP 7.0.14: $ php -v && php -r 'var_dump(strlen(exif_thumbnail("http://www.exiv2.org/include/img_1771.jpg")));' PHP 7.0.14-2+deb.sury.org~xenial+1 (cli) ( NTS ) Copyright (c) 1997-2016 The PHP Group Zend Engine v3.0.0, Copyright (c) 1998-2016 Zend Technologies with Zend OPcache v7.0.14-2+deb.sury.org~xenial+1, Copyright (c) 1999-2016, by Zend Technologies PHP Warning: exif_thumbnail(img_1771.jpg): IFD data bad offset: 0xFFFFFC52 length 0x01C2 in Command line code on line 1 int(0)Still the same on 5.6.30 (freebsd): php -v && php -r 'var_dump(strlen(exif_thumbnail("http://www.exiv2.org/include/img_1771.jpg")));' PHP 5.6.30 (cli) (built: Jan 21 2017 01:17:54) Copyright (c) 1997-2016 The PHP Group Zend Engine v2.6.0, Copyright (c) 1998-2016 Zend Technologies PHP Warning: exif_thumbnail(img_1771.jpg): IFD data bad offset: 0xFFFFFC52 length 0x01C2 in Command line code on line 1 int(0)This is pretty ridiculous that it is still around. I will try to revert back to 5.4! Here is the log for the latest that I tried: PHP 7.1.1 (cli) (built: Feb 13 2017 10:05:49) ( NTS ) Copyright (c) 1997-2017 The PHP Group Zend Engine v3.1.0, Copyright (c) 1998-2017 Zend Technologies with Zend OPcache v7.1.1, Copyright (c) 1999-2017, by Zend Technologies with Xdebug v2.5.0, Copyright (c) 2002-2016, by Derick Rethans PHP Warning: exif_thumbnail(img_1771.jpg): IFD data bad offset: 0xFFFFFC52 length 0x01C2 in Command line code on line 1 PHP Stack trace: PHP 1. {main}() Command line code:0 PHP 2. exif_thumbnail() Command line code:1 Warning: exif_thumbnail(img_1771.jpg): IFD data bad offset: 0xFFFFFC52 length 0x01C2 in Command line code on line 1 Call Stack: 0.0001 348240 1. {main}() Command line code:0 0.0001 348240 2. exif_thumbnail() Command line code:1 Command line code:1: int(0)Still getting this error on 7.0.15... any more info needed from my config? ---- attributes of image file ---- -rwxrwxrwx 1 root root 2839434 Mar 31 2013 IMG_4741.JPG* ---- source php script ---- <?php $file='IMG_4741.JPG'; $image = exif_thumbnail($file, $width, $height, $type); echo "length is :" . strlen($image); ?> ---- output of running the script ---- php phpBug.php PHP Warning: exif_thumbnail(IMG_4741.JPG): IFD data bad offset: 0xFFFFFCF2 length 0x0ED8 in /home/crberry/familyarchive/php/phpBug.php on line 3 length is :0 ---- php -v PHP 7.0.15-0ubuntu0.16.04.4 (cli) ( NTS ) Copyright (c) 1997-2017 The PHP Group Zend Engine v3.0.0, Copyright (c) 1998-2017 Zend Technologies with Zend OPcache v7.0.15-0ubuntu0.16.04.4, Copyright (c) 1999-2017, by Zend Technologies ---- uname -a Linux crberry-ThinkPad-R50e 4.4.0-66-generic #87-Ubuntu SMP Fri Mar 3 15:27:09 UTC 2017 i686 i686 i686 GNU/LinuxStill broken in PHP 5.6.30 :( $ php -v && php -r 'var_dump(strlen(exif_thumbnail("http://www.exiv2.org/include/img_1771.jpg")));' PHP 5.6.30-0+deb8u1 (cli) (built: Feb 8 2017 08:50:21) Copyright (c) 1997-2016 The PHP Group Zend Engine v2.6.0, Copyright (c) 1998-2016 Zend Technologies with Zend OPcache v7.0.6-dev, Copyright (c) 1999-2016, by Zend Technologies PHP Warning: exif_thumbnail(img_1771.jpg): IFD data bad offset: 0xFFFFFC52 length 0x01C2 in Command line code on line 1 Warning: exif_thumbnail(img_1771.jpg): IFD data bad offset: 0xFFFFFC52 length 0x01C2 in Command line code on line 1 int(0)