Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

exif_read_data - Incorrect APP1 Exif Identifier Code

Tags:

php

image

exif

I have problem with some of my photos when i want to read EXIF data.

My code below:

$exif_date = exif_read_data($file_path,  'IFD0');

With some images i get warrning: Message: exif_read_data(001.jpg) [function.exif-read-data]: Incorrect APP1 Exif Identifier Code

My question is: how can I awoid this warrning, can I check somehow if app1 is correct before exif_read? Thanks for help.

like image 790
baranq Avatar asked Nov 12 '11 18:11

baranq


1 Answers

For the quick answer, take a look at the last rows of this post.

I think some code is still missing. I came exactly across the same problem and after searching I found multiple websites related to this problem:

http://drupal.org/node/556970 a bug report with 2 solutions:

  1. simply put an @ in front of exif_read_data
  2. check $imageinfo['APP1'] if it contains Exif

After reading dcro's answer here, I found out that the second parameter of getimagesize() returns such an $imageinfo array. Now I tested one of my images with the following code:

<?php
getimagesize("test.jpg", $info);
var_dump($info);
?>

This returned the following:

array(1) {
  ["APP1"]=>
  string(434) "http://ns.adobe.com/xap/1.0/<?xpacket begin="" id="W5M0MpCehiHzreSzNTczkc9d"?>
<x:xmpmeta xmlns:x="adobe:ns:meta/" x:xmptk="Exempi + XMP Core 4.1.1">
 <rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#">
  <rdf:Description rdf:about=""
    xmlns:dc="http://purl.org/dc/elements/1.1/">
   <dc:type>Image</dc:type>
   <dc:format>image/jpeg</dc:format>
  </rdf:Description>
 </rdf:RDF>
</x:xmpmeta>

<?xpacket end="w"?>"
}

This btw. doesn't look like Exif. This looks more like XMP, but the funny part is that for example the exiftool finds some exif data (orientation for example). In the XMP specification I found that it is possible to have XMP and Exif data side by side in one file (page 18). Further search revealed that there are script like this one to extract Exif from XMP.

Anyway, since

  1. getimagesize() does not give me usable information about the Exif in my picture and
  2. the stated script shows that in my image the Exif data is not embedded into the XMP data and
  3. it simply works to suppress the exif-read-data() warning

I will still use the @exif-read-data($file_path) solution.

like image 72
JepZ Avatar answered Oct 01 '22 22:10

JepZ