php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #66771 exif_read_data returns malformed array
Submitted: 2014-02-25 18:19 UTC Modified: 2016-08-14 04:22 UTC
Votes:1
Avg. Score:3.0 ± 0.0
Reproduced:0 of 0 (0.0%)
From: peter at oncefuture dot com Assigned:
Status: No Feedback Package: EXIF related
PHP Version: 5.4.25 OS: Linux
Private report: No CVE-ID: None
Have you experienced this issue?
Rate the importance of this bug to you:

 [2014-02-25 18:19 UTC] peter at oncefuture dot com
Description:
------------
exif_read_data returns malformed arrays (missing a closing parens) when reading from certain image files that come straight out of the camera (ie. no processing in any image manipulation/management program like photoshop). I can reproduce this on files from Samsung, Nikon, etc.




Test script:
---------------
$exif = @exif_read_data( $file );
print_r($exif, true);

Test image files are here: http://goo.gl/Ry5fG6



Expected result:
----------------
Produces a malformed array without a closing paren:

Array
(
    [FileName] => Samsung-Galaxy-S3-123.jpg
    [FileDateTime] => 1393350070
    [FileSize] => 1811414
    [FileType] => 2
    [MimeType] => image/jpeg
    [SectionsFound] => ANY_TAG, IFD0, THUMBNAIL, EXIF, INTEROP
    [COMPUTED] => Array
        (
            [html] => width="3264" height="2448"
            [Height] => 2448
            [Width] => 3264
            [IsColor] => 1
            [ByteOrderMotorola] => 0
            [ApertureFNumber] => f/2.6
            [UserComment] => ø;
            [Thumbnail.FileType] => 2
            [Thumbnail.MimeType] => image/jpeg
            [Thumbnail.Height] => 120
            [Thumbnail.Width] => 160
        )

    [ImageWidth] => 3264
    [ImageLength] => 2448
    [Make] => SAMSUNG
    [Model] => GT-I9300
    [Orientation] => 1
    [XResolution] => 72/1
    [YResolution] => 72/1
    [ResolutionUnit] => 2
    [Software] => I9300XXEMA2
    [DateTime] => 2013:03:22 08:25:41
    [YCbCrPositioning] => 1
    [Exif_IFD_Pointer] => 224
    [THUMBNAIL] => Array
        (
            [ImageWidth] => 160
            [ImageLength] => 120
            [Compression] => 6
            [Orientation] => 1
            [XResolution] => 72/1
            [YResolution] => 72/1
            [ResolutionUnit] => 2
            [JPEGInterchangeFormat] => 5046
            [JPEGInterchangeFormatLength] => 7730
        )

    [ExposureTime] => 1/1444
    [FNumber] => 26/10
    [ExposureProgram] => 3
    [ISOSpeedRatings] => 80
    [ExifVersion] => 0220
    [DateTimeOriginal] => 2013:03:22 08:25:41
    [DateTimeDigitized] => 2013:03:22 08:25:41
    [ComponentsConfiguration] => 
)

Actual result:
--------------
Array
(
    [FileName] => Samsung-Galaxy-S3-123.jpg
    [FileDateTime] => 1393350070
    [FileSize] => 1811414
    [FileType] => 2
    [MimeType] => image/jpeg
    [SectionsFound] => ANY_TAG, IFD0, THUMBNAIL, EXIF, INTEROP
    [COMPUTED] => Array
        (
            [html] => width="3264" height="2448"
            [Height] => 2448
            [Width] => 3264
            [IsColor] => 1
            [ByteOrderMotorola] => 0
            [ApertureFNumber] => f/2.6
            [UserComment] => ø;
            [Thumbnail.FileType] => 2
            [Thumbnail.MimeType] => image/jpeg
            [Thumbnail.Height] => 120
            [Thumbnail.Width] => 160
        )

    [ImageWidth] => 3264
    [ImageLength] => 2448
    [Make] => SAMSUNG
    [Model] => GT-I9300
    [Orientation] => 1
    [XResolution] => 72/1
    [YResolution] => 72/1
    [ResolutionUnit] => 2
    [Software] => I9300XXEMA2
    [DateTime] => 2013:03:22 08:25:41
    [YCbCrPositioning] => 1
    [Exif_IFD_Pointer] => 224
    [THUMBNAIL] => Array
        (
            [ImageWidth] => 160
            [ImageLength] => 120
            [Compression] => 6
            [Orientation] => 1
            [XResolution] => 72/1
            [YResolution] => 72/1
            [ResolutionUnit] => 2
            [JPEGInterchangeFormat] => 5046
            [JPEGInterchangeFormatLength] => 7730
        )

    [ExposureTime] => 1/1444
    [FNumber] => 26/10
    [ExposureProgram] => 3
    [ISOSpeedRatings] => 80
    [ExifVersion] => 0220
    [DateTimeOriginal] => 2013:03:22 08:25:41
    [DateTimeDigitized] => 2013:03:22 08:25:41
    [ComponentsConfiguration] =>

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2014-02-26 00:18 UTC] chrispmaiden at gmail dot com
I'm not sure I am testing this correctly but I cannot reproduce this.

I download 5.4.25 source code and did the following:

./configure --prefix=/home/matason/php --enable-exif
make
make install

Then I created a PHP file:

<?php
// /home/matason/exif-test.php
$exif = exif_read_data('/home/matason/Downloads/images/Samsung Galaxy S3 (1).jpg');
print_r($exif);

And ran it with:
/home/matason/php/bin/php -f /home/matason/exif-test.php

And here's the output (note that it includes the closing paren):

Array
(
    [FileName] => Samsung Galaxy S3 (1).jpg
    [FileDateTime] => 1363958740
    [FileSize] => 1811414
    [FileType] => 2
    [MimeType] => image/jpeg
    [SectionsFound] => ANY_TAG, IFD0, THUMBNAIL, EXIF, INTEROP
    [COMPUTED] => Array
        (
            [html] => width="3264" height="2448"
            [Height] => 2448
            [Width] => 3264
            [IsColor] => 1
            [ByteOrderMotorola] => 0
            [ApertureFNumber] => f/2.6
            [UserComment] => �;
            [Thumbnail.FileType] => 2
            [Thumbnail.MimeType] => image/jpeg
            [Thumbnail.Height] => 120
            [Thumbnail.Width] => 160
        )

    [ImageWidth] => 3264
    [ImageLength] => 2448
    [Make] => SAMSUNG
    [Model] => GT-I9300
    [Orientation] => 1
    [XResolution] => 72/1
    [YResolution] => 72/1
    [ResolutionUnit] => 2
    [Software] => I9300XXEMA2
    [DateTime] => 2013:03:22 08:25:41
    [YCbCrPositioning] => 1
    [Exif_IFD_Pointer] => 224
    [THUMBNAIL] => Array
        (
            [ImageWidth] => 160
            [ImageLength] => 120
            [Compression] => 6
            [Orientation] => 1
            [XResolution] => 72/1
            [YResolution] => 72/1
            [ResolutionUnit] => 2
            [JPEGInterchangeFormat] => 5046
            [JPEGInterchangeFormatLength] => 7730
        )

    [ExposureTime] => 1/1444
    [FNumber] => 26/10
    [ExposureProgram] => 3
    [ISOSpeedRatings] => 80
    [ExifVersion] => 0220
    [DateTimeOriginal] => 2013:03:22 08:25:41
    [DateTimeDigitized] => 2013:03:22 08:25:41
    [ComponentsConfiguration] =>
    [ShutterSpeedValue] => 2687/256
    [ApertureValue] => 276/100
    [BrightnessValue] => 2234/256
    [ExposureBiasValue] => 0/10
    [MaxApertureValue] => 276/100
    [MeteringMode] => 2
    [Flash] => 0
    [FocalLength] => 37/10
    [MakerNote] => 0100 @P
                          Z
    [UserComment] => �;K
�xV4xV4xV4xV4`A9�@

������CALGDFD06Cur.GDFI02CML018001001509002901090502010D010D010D090D�	�&TUNA��
XX	t l����U��w����EK�����
	���                   US����FLFLSVN#
RX	X	R	y	Z	^JV�
8JKJK���x�}�                                "
            B��
X	g"��t l����U��w����EK�����
                                  US����JKJK""""""""""""""""""""""""!""""""!"!"!"""""""""""���!"!"!"!"!"!"!"""!"!"!"!"!"������������	��	��	��	��	��	��	��	������	��	��	��	��	��	��	��	�����	��	��	��	�������������	��	���������������	��	��	�������������	��	��	��	��	�����������	��	��	��	��	��	��	����������	��	��	��	��	��	��	��	JKJK�%��*�lM����>�V%��"���"���"���
                                                                                                                                  )AFAFAFAF=G (AFAFް�
�xR�)�)�ss\&�Ƴ6n������ΊFߛW�޼���40��
                                   @7�>
    [FlashPixVersion] => 0100
    [ColorSpace] => 1
    [ExifImageWidth] => 3264
    [ExifImageLength] => 2448
    [InteroperabilityOffset] => 4886
    [ExposureMode] => 0
    [WhiteBalance] => 0
    [SceneCaptureType] => 0
    [ImageUniqueID] => GDFI02
    [InterOperabilityIndex] => R98
    [InterOperabilityVersion] => 0100
)
 [2016-08-05 06:00 UTC] kalle@php.net
-Status: Open +Status: Feedback
 [2016-08-05 06:00 UTC] kalle@php.net
Please try using this snapshot:

  http://snaps.php.net/php-trunk-latest.tar.gz
 
For Windows:

  http://windows.php.net/snapshots/

Could you try to check with the recent fixes made to exif from the master branch, which will eventually turn into 7.2 if these have fixed the issue? I have recently added support for Samsung as one of the mentioned formats.

Side note, some editors can cause some exif data to be saved incorrectly due to their offsets that varies, and they are not bound to the header of the file either hence why some editors can potentially cause loss of exif data or corrupted data which is sadly out of our hands to fix.
 [2016-08-14 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.
 
PHP Copyright © 2001-2021 The PHP Group
All rights reserved.
Last updated: Sat Jul 31 06:01:24 2021 UTC