Exif_read_data - Invalid Exif APP1 identifier code

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

My code is 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]: Invalid Exif ID code APP1

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

+6
source share
2 answers

You can use the getimagesize() PHP function to extract the APP tokens from the file, and then check if the APP1 token really contains EXIF ​​data (the contents for this token should start with "Exif")

0
source

For a quick response, review the last lines of this message.

I think the code is still missing. I came exactly on the same problem, and after searching I found several websites related to this problem:

http://drupal.org/node/556970 error report with two solutions:

  • just put @ before exif_read_data
  • check $imageinfo['APP1'] if it contains Exif

After reading the dcro answer here, I found out that the second getimagesize() parameter returns such an $imageinfo . Now I checked 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 is the way. not like Exif. This is more like XMP , but the fun part is that, for example, exiftool finds some exif data (like orientation). In the XMP specification, I found that you can store XMP and Exif data in one file in a single file (p. 18). A further search revealed that there is a script like this to extract Exif from XMP .

Anyway, since

  • getimagesize () does not give me useful information about Exif in my picture and
  • the specified script shows that in my image the Exif data is not embedded in the XMP data and
  • it just works to suppress exif-read-data () warning

I am still using @exif-read-data($file_path) .

+12
source

Source: https://habr.com/ru/post/901357/


All Articles