読者です 読者をやめる 読者になる 読者になる

PHP7のexif_read_dataがなんか変

PC

 php7になって、exif_read_dataがなんか変。
 以下はexif_read_dataで読み込んだデータ配列をprint_rしたもの。

Array
(
    [FileName] => DSC03874.JPG
    [FileDateTime] => 1476600328
    [FileSize] => 1964293
    [FileType] => 2
    [MimeType] => image/jpeg
    [SectionsFound] => ANY_TAG, IFD0, EXIF
    [COMPUTED] => Array
        (
            [html] => width="2592" height="1944"
            [Height] => 1944
            [Width] => 2592
            [IsColor] => 1
            [ByteOrderMotorola] => 0
            [ApertureFNumber] => f/3.5
        )

    [ImageDescription] =>                                
    [Make] => SONY
    [Model] => DSC-TX30
    [Orientation] => 1
    [XResolution] => 350/1
    [YResolution] => 350/1
    [ResolutionUnit] => 2
    [Software] => DSC-TX30 v1.00
    [DateTime] => 2016:10:16 15:45:28
    [YCbCrPositioning] => 2
    [ExposureTime] => 1/400
    [FNumber] => 35/10
    [ExposureProgram] => 2
    [ISOSpeedRatings] => 80
    [UndefinedTag:0x8830] => 2
    [UndefinedTag:0x8832] => 80
    [ExifVersion] => 0230
    [DateTimeOriginal] => 2016:10:16 15:45:28
    [DateTimeDigitized] => 2016:10:16 15:45:28
    [ComponentsConfiguration] => 
    [CompressedBitsPerPixel] => 2/1
    [BrightnessValue] => 21984/2560
    [ExposureBiasValue] => 0/10
    [MaxApertureValue] => 926/256
    [MeteringMode] => 5
    [LightSource] => 0
    [Flash] => 16
    [FocalLength] => 470/100
)

 GPS系のデータが格納されていない。同じファイルをjheadしてみると

File name    : /home/kazz/Photo/20161016郡山若松/DSC03874.JPG
File size    : 1964293 bytes
File date    : 2016:10:16 15:45:28
Camera make  : SONY
Camera model : DSC-TX30
Date/Time    : 2016:10:16 15:45:28
Resolution   : 2592 x 1944
Flash used   : No
Focal length :  4.7mm
Exposure time: 0.0025 s  (1/400)
Aperture     : f/3.5
ISO equiv.   : 80
Whitebalance : Auto
Metering Mode: pattern
Exposure     : program (auto)
GPS Latitude : N 37d 40m 38.1s
GPS Longitude: E 139d 53m 42.4s
JPEG Quality : 95

 となっているので、GPS系のデータが書き込まれていないわけではない。なんでや。

kazz@oscar ~# php -v
PHP 7.0.8-0ubuntu0.16.04.3 (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.3, Copyright (c) 1999-2016, by Zend Technologies
kazz@oscar ~#

検索してこんなの発見。

Hello,

I had the same issue and debugged it to the same problem (makernotes in exif).
I found a bug in PHP bug tracker which seems to be the cause of the issue :
https://bugs.php.net/bug.php?id=72682

I was using php 7.0.8. An upgrade to php 7.0.10 fixed the problem for me.

For ubuntu 16.04 I used this PPA :
https://launchpad.net/~ondrej/+archive/ubuntu/php

I'll add the same comment in Github issue #520 as it seems to be the same issue :
[Github] Piwigo issue #520

ありがちなバグってやつですか。アップグレードしてみる。

kazz@oscar ~# php -v
PHP 7.0.12-1+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.12-1+deb.sury.org~xenial+1, Copyright (c) 1999-2016, by Zend Technologies
kazz@oscar ~#

で、出力。

Array
(
    [FileName] => DSC03874.JPG
    [FileDateTime] => 1476600328
    [FileSize] => 1964293
    [FileType] => 2
    [MimeType] => image/jpeg
    [SectionsFound] => ANY_TAG, IFD0, THUMBNAIL, EXIF, GPS, INTEROP
    [COMPUTED] => Array
        (
            [html] => width="2592" height="1944"
            [Height] => 1944
            [Width] => 2592
            [IsColor] => 1
            [ByteOrderMotorola] => 0
            [ApertureFNumber] => f/3.5
            [UserComment] => 
            [UserCommentEncoding] => UNDEFINED
            [Thumbnail.FileType] => 2
            [Thumbnail.MimeType] => image/jpeg
        )

    [ImageDescription] =>                                
    [Make] => SONY
    [Model] => DSC-TX30
    [Orientation] => 1
    [XResolution] => 350/1
    [YResolution] => 350/1
    [ResolutionUnit] => 2
    [Software] => DSC-TX30 v1.00
    [DateTime] => 2016:10:16 15:45:28
    [YCbCrPositioning] => 2
    [Exif_IFD_Pointer] => 298
    [GPS_IFD_Pointer] => 38726
    [UndefinedTag:0xC4A5] => PrintIM0300
    [THUMBNAIL] => Array
        (
            [Compression] => 6
            [ImageDescription] =>                                
            [Make] => SONY
            [Model] => DSC-TX30
            [Orientation] => 1
            [XResolution] => 72/1
            [YResolution] => 72/1
            [ResolutionUnit] => 2
            [Software] => DSC-TX30 v1.00
            [DateTime] => 2016:10:16 15:45:28
            [JPEGInterchangeFormat] => 39122
            [JPEGInterchangeFormatLength] => 10726
            [YCbCrPositioning] => 2
        )

    [ExposureTime] => 1/400
    [FNumber] => 35/10
    [ExposureProgram] => 2
    [ISOSpeedRatings] => 80
    [UndefinedTag:0x8830] => 2
    [UndefinedTag:0x8832] => 80
    [ExifVersion] => 0230
    [DateTimeOriginal] => 2016:10:16 15:45:28
    [DateTimeDigitized] => 2016:10:16 15:45:28
    [ComponentsConfiguration] => 
    [CompressedBitsPerPixel] => 2/1
    [BrightnessValue] => 21984/2560
    [ExposureBiasValue] => 0/10
    [MaxApertureValue] => 926/256
    [MeteringMode] => 5
    [LightSource] => 0
    [Flash] => 16
    [FocalLength] => 470/100
    [MakerNote] => SONY DSC 
    [UserComment] => 
    [FlashPixVersion] => 0100
    [ColorSpace] => 1
    [ExifImageWidth] => 2592
    [ExifImageLength] => 1944
    [InteroperabilityOffset] => 38696
    [FileSource] => 
    [SceneType] => 
    [CustomRendered] => 0
    [ExposureMode] => 0
    [WhiteBalance] => 0
    [DigitalZoomRatio] => 16/16
    [SceneCaptureType] => 0
    [Contrast] => 0
    [Saturation] => 0
    [Sharpness] => 0
    [UndefinedTag:0xA432] => Array
        (
            [0] => 470/100
            [1] => 2350/100
            [2] => 35/10
            [3] => 48/10
        )

    [GPSVersion] => 
    [GPSLatitudeRef] => N
    [GPSLatitude] => Array
        (
            [0] => 37/1
            [1] => 40/1
            [2] => 381/10
        )

    [GPSLongitudeRef] => E
    [GPSLongitude] => Array
        (
            [0] => 139/1
            [1] => 53/1
            [2] => 212/5
        )

    [GPSAltitude] => 265/1
    [InterOperabilityIndex] => R98
    [InterOperabilityVersion] => 0100
)

 無事戻りました。めでたしめでたし。

 しかし16.04 LTSでこんなバグのあるバージョンを標準のままにしているってどやねん。