Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

exif_read_data() giving odd errors on some images

Status
Not open for further replies.

dbrb2

Instructor
Jul 19, 2004
121
GB
Hi,
I have a directory full of photos, all taken at similar times with the same camera, and all of which I can view the exif data on using various programs. On my webpage, I extract the GPS info and a few other bits into an XML file for futher crunching. But for some reason the function fails on quite a lot of photos. Any ideas?

Examples of the errors can be seen here:


Cheers,

Ben
 
On close inspection of the php man pages, I see that this function validates the exif headers agains a standard. If my hearders do not match this standard, perhaps that would explain the problem. I wonder if there is a way to get the function not to care... (I can supress the errors, but it still returns no data)
 
Oh, btw, the code that extracts the exif email to XML is shown below. It should loop around every image in the current directoy, and if it has GPS information then it should enter the final if statement, where the extraction occurs.

if (is_dir($dir)) {
if ($dh = opendir($dir)) {
while (($file = readdir($dh))!== false) {
if(@GetImageSize($file)){
$exif = exif_read_data($file);


//print_r($exif);
if(@exif_read_data($file,'GPS')){
 
Ah...a bit more investigation has shown that the images giving those error messages fail the exif_read_data($file,'GPS') test that checks if there is GPS info in the header.

If I extract it anyway, then I get o for lat and long.

But I know this isn't correct, as my other readers can view the GPS info no probs...
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top