php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #72819 EXIF thumbnails not read anymore
Submitted: 2016-08-12 04:45 UTC Modified: 2017-07-11 08:50 UTC
Votes:30
Avg. Score:4.3 ± 0.9
Reproduced:28 of 28 (100.0%)
Same Version:8 (28.6%)
Same OS:11 (39.3%)
From: php dot bohwaz at miam dot kd2 dot org Assigned: kalle (profile)
Status: Closed Package: EXIF related
PHP Version: 5.6.25 OS: Debian Linux Jessie
Private report: No CVE-ID: None
View Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
If you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: php dot bohwaz at miam dot kd2 dot org
New email:
PHP Version: OS:

 

 [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)


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2016-08-12 04:46 UTC] php dot bohwaz at miam dot kd2 dot org
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)
 [2016-08-12 04:47 UTC] php dot bohwaz at miam dot kd2 dot org
(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)
 [2016-08-12 08:42 UTC] cmb@php.net
-Status: Open +Status: Feedback -Assigned To: +Assigned To: cmb
 [2016-08-12 08:42 UTC] cmb@php.net
This appears to be a duplicate of bug #72735, which has been fixed
as of PHP 5.6.25. Please try this version.
 [2016-08-12 09:33 UTC] php dot bohwaz at miam dot kd2 dot org
-Status: Feedback +Status: Assigned
 [2016-08-12 09:33 UTC] php dot bohwaz at miam dot kd2 dot org
Yup I saw that bug but the patch seems to only affect Samsung photos, and my problem happens with every photo I tried, so not sure how that patch would affect this issue.

In any case I will try with the git branch next week just to be sure.
 [2016-08-12 10:12 UTC] cmb@php.net
-Status: Assigned +Status: Feedback
 [2016-08-12 10:12 UTC] cmb@php.net
I've just checked the first image with PHP 5.6.24 and with the
current head of the PHP-5.6 branch. The former gives `int(0)`,
the latter `int(21004)`, so indeed the issue appears to have been
fixed.
 [2016-08-20 22:11 UTC] crberry50 at gmail dot com
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/Linux
 [2016-08-21 04:22 UTC] php-bugs at lists dot php dot net
No feedback was provided. The bug is being suspended because
we assume that you are no longer experiencing the problem.
If this is not the case and you are able to provide the
information that was requested earlier, please do so and
change the status of the bug back to "Re-Opened". Thank you.
 [2016-08-21 04:58 UTC] requinix@php.net
-Status: No Feedback +Status: Feedback
 [2016-08-21 04:58 UTC] requinix@php.net
72735 was fixed in PHP 7.0.10. To test with the 7.0 series you need to use at least that version.
 [2016-08-22 05:47 UTC] requinix@php.net
-PHP Version: 5.6.24 +PHP Version: 5.6.25
 [2016-08-22 05:47 UTC] requinix@php.net
Bug #72914 and I can both reproduce in 5.6.25.

@cmb, I see one commit that fixes 72735 and it looks like it's only in master.
https://github.com/php/php-src/commit/9c8c37854efe843e45228597837fc4b6aac59113
But @welting updated NEWS saying it's fixed in 5.6.25, 7.0.10, and 7.1.0beta3?
 [2016-08-22 06:29 UTC] cmb@php.net
-Status: Feedback +Status: Open
 [2016-08-22 08:01 UTC] cmb@php.net
-Status: Assigned +Status: Verified -Assigned To: cmb +Assigned To: kalle
 [2016-08-22 08:01 UTC] cmb@php.net
Indeed, Kalle's commit[1] is only in master, but there may have
been another commit that fixed the issue. Not sure.

Anyhow, I can confirm that this report and also bug 72914 are not
resolved with PHP 5.6.25. bug 72914 would be resolved with current
master; however, this very issue not.

@kalle Can you please have a look at these issues?

[1] <https://github.com/php/php-src/commit/9c8c3785>
 [2016-08-26 01:01 UTC] kalle@php.net
@cmb I have been fairly busy with some personal life things and moving in the past week or so, and it might continue and with Legion's release coming soon I'm not sure how much time I have, but in the case I do not something within a week or two, then please see if you can sync 5.6/7.0/7.1 with master
 [2016-11-02 11:21 UTC] stephan at vierkant dot org
php -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)
 [2016-12-19 09:21 UTC] egonfreeman at gmail dot com
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)
 [2017-01-24 14:43 UTC] martin at the-inspired-ones dot de
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)
 [2017-02-04 23:44 UTC] evil+php at piekielko dot pl
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)
 [2017-02-18 03:56 UTC] stephan dot hesmer at gmail dot com
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)
 [2017-03-25 00:18 UTC] crberry50 at gmail dot com
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/Linux
 [2017-05-12 02:37 UTC] php dot bohwaz at miam dot kd2 dot org
Still 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)
 [2017-07-07 10:20 UTC] kalle@php.net
Automatic comment on behalf of kalle
Revision: http://git.php.net/?p=php-src.git;a=commit;h=e6903d471e45177c248adfb4f1abdfdd5487d7bf
Log: * Fixed bug #72819 (EXIF thumbnails not read anymore) * Fixed bug #62523 (php crashes with segfault when exif_read_data called) * Fixed the poor test case for #62523, which was a HTML document
 [2017-07-07 10:20 UTC] kalle@php.net
-Status: Verified +Status: Closed
 [2017-07-07 10:20 UTC] kalle@php.net
-Status: Closed +Status: Verified
 [2017-07-07 10:20 UTC] kalle@php.net
-Status: Verified +Status: Closed
 [2017-07-07 10:20 UTC] kalle@php.net
The fix for this bug has been committed.

Snapshots of the sources are packaged every three hours; this change
will be in the next snapshot. You can grab the snapshot at
http://snaps.php.net/.

 For Windows:

http://windows.php.net/snapshots/
 
Thank you for the report, and for helping us make PHP better.


 [2017-07-11 02:41 UTC] php dot bohwaz at miam dot kd2 dot org
Finally, thank you so much :)

Could we get that merged in old PHP versions as well? Like PHP 5.6 and 7.0 and 7.1?

Thanks :)
 [2017-07-11 03:01 UTC] kalle@php.net
I will see if I can merge the changes to lower branches, but sadly there are quite a few that all build on each other so I will have to check with the RMs if its possible

Thanks for helping to make PHP even greater!
 [2017-07-11 03:08 UTC] php dot bohwaz at miam dot kd2 dot org
Sure, no worries if it's just impossible or too hard.

I tried to fix that bug a few months earlier but I didn't have enough knowledge of how EXIF worked to be able to fix it. So thanks :)

BTW I compiled and tested your patch and all my files that were failing are now working. So far so good!
 [2017-07-11 08:50 UTC] kalle@php.net
Awesome! Thank you very much for testing, keep reporting bugs if more should occur, I put myself as a maintainer of the EXIF extension, at least for now :)

I also added a lot more new MARKERNOTE formats to the base extension, like Sony
 [2017-07-12 05:48 UTC] crberry50 at gmail dot com
php7 is the default in Ubuntu 16.04 .. will the fix find it's way over to PHP 7.0.18-0ubuntu0.16.04.1 and the Ubuntu repos?  or should I start working on rolling back to v5
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Wed Dec 04 21:01:29 2024 UTC