2015-05-11 11 views
8

Pracuję, aby pobrać pewne informacje z plików JPEG dostarczonych do mojego klienta przez fotografa.Dane EXIF ​​(lub inne dane metadane) wyświetlane przez system Windows, ale PHP nie jest zgodne z

Kiedy zbadano pod Windows wszystkie obrazy zawierają dane w polu o nazwie Tagi:

enter image description here

enter image description here

zrobić kilka badań na pierwszy zrobiłem następujący scenariusz i jestem iteracji nad wpisami w nagłówki plików binarnych za pomocą poniższego kodu.

Czasami dostaję wartości dla ImageDescription. Często tekst w prawach autorskich i autorze, ale treść tagów nigdy tu nie pojawia się i jest to przechwytywanie treści, które klient chce zautomatyzować.

Czy ktoś może mi doradzić, w jaki sposób mogę uzyskać dostęp do zawartości pola Tagi?

Przesłana kopia pliku to here.

UPDATE - zmienił IDF0 do ANY_TAG i dodał 3rd argumentu prawda do exif_read_data (odpowiedzi) na Tiger-222 za. Dodano także wyjście print_r na koniec postu

UPDATE 2 Dodane o error_display() i ini_set() wywołuje, a także próbowali exif_read_data() 2. arg 0 w miejscu 'ANY_TAG' za https://php.net/manual/en/function.exif-read-data.php

<?php 
    ini_set('display_errors', 1); 
    ini_set('exif.encode_unicode', 'UTF-8'); // To see WINXP values 
    error_reporting(-1);   
    $n = (intval($_GET['n'])) ? $_GET['n'] : 99; 
    echo "ANI_$n.jpg:<br />\n"; 
    $exif = exif_read_data("ANI_$n.jpg", 'ANY_TAG', true); 
    echo $exif===false ? "No header data found.<br />\n" : "Image contains the following headers:<br><br />\n"; 

    if ($exif) { 
     foreach ($exif as $key => $section) { 
      if (is_array($section)) { 
       foreach ($section as $name => $val) { 
        echo "$key.$name: $val<br />\n"; 
       } 
      } else { 
       echo "$key: $section<br>\n"; 
      } 
     } 
    } 
?> 

Poniżej znajduje się treść porzucona przez skrypt dla dźwigu koklusz obrazka:

ANI_69.jpg: 
Image contains the following headers: 

FileName: ANI_69.jpg 
FileDateTime: 1428255617 
FileSize: 2448245 
FileType: 2 
MimeType: image/jpeg 
SectionsFound: ANY_TAG, IFD0, THUMBNAIL, EXIF 
COMPUTED.html: width="1798" height="2697" 
COMPUTED.Height: 2697 
COMPUTED.Width: 1798 
COMPUTED.IsColor: 1 
COMPUTED.ByteOrderMotorola: 0 
COMPUTED.Copyright: Photographer name here 
COMPUTED.Thumbnail.FileType: 2 
COMPUTED.Thumbnail.MimeType: image/jpeg 
ImageWidth: 1798 
ImageLength: 2697 
BitsPerSample.0: 8 
BitsPerSample.1: 8 
BitsPerSample.2: 8 
PhotometricInterpretation: 2 
Orientation: 1 
SamplesPerPixel: 3 
XResolution: 1000000/10000 
YResolution: 1000000/10000 
ResolutionUnit: 2 
Software: Adobe Photoshop CS6 (Macintosh) 
DateTime: 2014:12:28 19:17:36 
Artist: Photographer name here 
Copyright: Photographer name here 
Exif_IFD_Pointer: 316 
THUMBNAIL.Compression: 6 
THUMBNAIL.XResolution: 72/1 
THUMBNAIL.YResolution: 72/1 
THUMBNAIL.ResolutionUnit: 2 
THUMBNAIL.JPEGInterchangeFormat: 554 
THUMBNAIL.JPEGInterchangeFormatLength: 3211 
ExifVersion: 0230 
DateTimeOriginal: 2014:11:03 11:14:27 
DateTimeDigitized: 2014:11:03 11:14:27 
SubSecTimeOriginal: 76 
SubSecTimeDigitized: 76 
ColorSpace: 65535 
ExifImageWidth: 1798 
ExifImageLength: 2697 

Oto zrzut $ exif od $exif = exif_read_data("ANI_$n.jpg", 'ANY_TAG', true);

Array 
(
    [FILE] => Array 
     (
      [FileName] => ANI_69.jpg 
      [FileDateTime] => 1428255617 
      [FileSize] => 2448245 
      [FileType] => 2 
      [MimeType] => image/jpeg 
      [SectionsFound] => ANY_TAG, IFD0, THUMBNAIL, EXIF 
     ) 

    [COMPUTED] => Array 
     (
      [html] => width="1798" height="2697" 
      [Height] => 2697 
      [Width] => 1798 
      [IsColor] => 1 
      [ByteOrderMotorola] => 0 
      [Copyright] => Digital Roux Photography LLC 
      [Thumbnail.FileType] => 2 
      [Thumbnail.MimeType] => image/jpeg 
     ) 

    [IFD0] => Array 
     (
      [ImageWidth] => 1798 
      [ImageLength] => 2697 
      [BitsPerSample] => Array 
       (
        [0] => 8 
        [1] => 8 
        [2] => 8 
       ) 

      [PhotometricInterpretation] => 2 
      [Orientation] => 1 
      [SamplesPerPixel] => 3 
      [XResolution] => 1000000/10000 
      [YResolution] => 1000000/10000 
      [ResolutionUnit] => 2 
      [Software] => Adobe Photoshop CS6 (Macintosh) 
      [DateTime] => 2014:12:28 19:17:36 
      [Artist] => Digital Roux Photography LLC 
      [Copyright] => Digital Roux Photography LLC 
      [Exif_IFD_Pointer] => 316 
     ) 

    [THUMBNAIL] => Array 
     (
      [Compression] => 6 
      [XResolution] => 72/1 
      [YResolution] => 72/1 
      [ResolutionUnit] => 2 
      [JPEGInterchangeFormat] => 554 
      [JPEGInterchangeFormatLength] => 3211 
     ) 

    [EXIF] => Array 
     (
      [ExifVersion] => 0230 
      [DateTimeOriginal] => 2014:11:03 11:14:27 
      [DateTimeDigitized] => 2014:11:03 11:14:27 
      [SubSecTimeOriginal] => 76 
      [SubSecTimeDigitized] => 76 
      [ColorSpace] => 65535 
      [ExifImageWidth] => 1798 
      [ExifImageLength] => 2697 
     ) 

) 

enter image description here

+0

afair te znaczniki nie są przechowywane wewnątrz jpg, okna posiada własną bazę dla nich –

+0

@Lashane dodali zrzut ekranu pokazujący znaczniki w kodzie binarnym. Wszystkie one przychodzą do mnie masowo z metkami w nich; mój lokalny system Windows nie mógł ich dodać ... – jerrygarciuh

+1

Czy możesz dołączyć zdjęcie do testów? –

Odpowiedz

7

W trzy punktów (dzięki jerrygarciuh za cierpliwość i pomoc).

1) Aby sprawdzić, dodatkowe informacje, po prostu przechodzi do trzeciego argumentu true:

$exif = exif_read_data("ANI_$n.jpg", 'IFD0', true); 

Jak wyjaśniono here, wymusza konwersję do tablicy, aby uniknąć konfliktów między sekcjami. Znajdziesz tagi pod słowem kluczowym IFD0.Keywords.

2)There is an issue z WINXP.Keywords. Aby poprawnie wyświetlić te informacje, wystarczy ustawić kodowanie do UFT-8:

ini_set('exif.encode_unicode', 'UTF-8'); 

3) Dzięki this question from Ferdy, dodatkowe informacje setted przez Lightroom można odczytać za pomocą iptcparse.Jest to pełny scenariusz:

ini_set('exif.encode_unicode', 'UTF-8'); // To see WINXP values 

// Exif informations -- limited by PHP 
$exif = exif_read_data("ANI_$n.jpg", 'ANY_TAG', true); 
print_r($exif); 

// Additionnal informations from Lightroom 
getimagesize("ANI_$n.jpg", $infos); 
if (isset($infos['APP13'])) { 
    print_r(iptcparse($infos['APP13'])); 
} 

wyjściowa:

Array 
(
    [FILE] => Array 
     (
      [FileName] => ANI_69.or.jpg 
      [FileDateTime] => 1431382165 
      [FileSize] => 2450950 
      [FileType] => 2 
      [MimeType] => image/jpeg 
      [SectionsFound] => ANY_TAG, IFD0, THUMBNAIL, EXIF, WINXP 
     ) 

    [COMPUTED] => Array 
     (
      [html] => width="1798" height="2697" 
      [Height] => 2697 
      [Width] => 1798 
      [IsColor] => 1 
      [ByteOrderMotorola] => 1 
      [Copyright] => Digital Roux Photography LLC 
      [Thumbnail.FileType] => 2 
      [Thumbnail.MimeType] => image/jpeg 
     ) 

    [IFD0] => Array 
     (
      [ImageWidth] => 1798 
      [ImageLength] => 2697 
      [BitsPerSample] => Array 
       (
        [0] => 8 
        [1] => 8 
        [2] => 8 
       ) 

      [PhotometricInterpretation] => 2 
      [ImageDescription] => Rusty Costanza/Digital Roux Photography 
      [Orientation] => 1 
      [SamplesPerPixel] => 3 
      [XResolution] => 1000000/10000 
      [YResolution] => 1000000/10000 
      [ResolutionUnit] => 2 
      [Software] => Adobe Photoshop CS6 (Macintosh) 
      [DateTime] => 2014:12:28 19:17:36 
      [Artist] => Digital Roux Photography LLC 
      [Copyright] => Digital Roux Photography LLC 
      [Exif_IFD_Pointer] => 2468 
      [Title] => Rusty Costanza/Digital Roux Photography 
      [Keywords] => whooping crane 
      [UndefinedTag:0xEA1C] => � 
     ) 

    [THUMBNAIL] => Array 
     (
      [Compression] => 6 
      [XResolution] => 72/1 
      [YResolution] => 72/1 
      [ResolutionUnit] => 2 
      [JPEGInterchangeFormat] => 4894 
      [JPEGInterchangeFormatLength] => 3371 
     ) 

    [EXIF] => Array 
     (
      [ExifVersion] => 0230 
      [DateTimeOriginal] => 2014:11:03 11:14:27 
      [DateTimeDigitized] => 2014:11:03 11:14:27 
      [SubSecTimeOriginal] => 76 
      [SubSecTimeDigitized] => 76 
      [ColorSpace] => 65535 
      [ExifImageWidth] => 1798 
      [ExifImageLength] => 2697 
      [UndefinedTag:0xEA1C] => � 
     ) 

    [WINXP] => Array 
     (
      [Title] => 刀甀猀琀礀 䌀漀猀琀愀渀稀愀 ⼀ 䐀椀最椀琀愀氀 刀漀甀砀 倀栀漀琀漀最爀愀瀀栀礀ഀ 
      [Keywords] => 眀栀漀漀瀀椀渀最 挀爀愀渀攀 
     ) 
) 

Array 
(
    [1#090] => Array 
     (
      [0] => 
     ) 

    [2#000] => Array 
     (
      [0] => 
     ) 

    [2#055] => Array 
     (
      [0] => 20141103 
     ) 

    [2#060] => Array 
     (
      [0] => 111427+0000 
     ) 

    [2#090] => Array 
     (
      [0] => New Orleans 
     ) 

    [2#025] => Array 
     (
      [0] => whooping crane 
     ) 

    [2#080] => Array 
     (
      [0] => Digital Roux Photography LLC 
     ) 

    [2#120] => Array 
     (
      [0] => Rusty Costanza/Digital Roux Photography 
     ) 

    [2#116] => Array 
     (
      [0] => Digital Roux Photography LLC 
     ) 

    [2#221] => Array 
     (
      [0] => 0:0:0:-00001 
     ) 

    [2#062] => Array 
     (
      [0] => 20141103 
     ) 
) 

Nawiasem mówiąc, ładne zdjęcie;)

+0

Dziękujemy! Może mam problemy z wersją exif_read_data(). Kiedy realizowany tylko wyjście get jest ' ANI_69.jpg:
Obraz zawiera następujące nagłówki:

ImageWidth: 1798 ImageLength: 2697 0: 8 1: 8 2: 8 photometricinterpretation: 2 Orientacja: 1 samplesperpixel: 3 xresolution: 1000000/10000 yresolution: 1000000/10000 ResolutionUnit: 2 Oprogramowanie: Adobe Photoshop CS6 (Macintosh) DateTime: 2014: 12: 28 19:17:36 Wykonawca: fotograf nazwa tutaj Prawa autorskie: Nazwa fotografa tutaj Exif_IFD_Pointer: 316' – jerrygarciuh

+1

'Exif_IFD_Pointer' powinien być taki sam jak mogę ... Czy mógłbyś wyświetlać błędy i ostrzeżenia tak jak ja? –

+0

Dodałem 'error_reporting (E_ALL)' właśnie teraz, ale bez zmian w wynikach. Również nie widzę WinXP ani żadnego wpisu dla słów kluczowych w wynikach. Zrzut $ exif został dodany do posta. – jerrygarciuh

Powiązane problemy