Read_exif_data error?

software development

#1

http://bugs.php.net/bug.php?id=40073 was supposed to be fixed in 5.2.1, but this call:

$info = exif_read_data(’/home/edalzell/thedalzells.org/photos/November/IMG_2973.JPG’);

fails.

Any ideas why?


#2

How is it “failing” and what exactly are you trying to do with your code?

It looks to me as though you are not passing enough parameters; the examples in the php.net manual work fine for me using either PHP4.4.7 or 5.2.2/3 on DreamHost. :wink:

http://us.php.net/manual/en/function.exif-read-data.php

Edited: I just re-read your message and the bug report, and realized I misinterpreted your problem. Sorry about that! How many directory levels can you go before it “breaks”?

–rlparker


#3

Doesn’t matter where it is, same error.


#4

well, now I am even more confused … as the function seems to work as expected for me using a short path (for instance, in the same directory or one level down, as in the examples on php.net)

–rlparker


#5

I think you might be overlooking something.

First of all, we don’t know if the OP code is checking for the existence of the file before the call to read_exif_data.

Second and more important don’t forget that DreamHost links /home/username to /home/.glob/username. If the code that opens the file won’t follow links you will get an error. Please modify your testcase appropiately if you haven’t done so already.

$relative_path = ‘filename.jpg’; # or ‘./filename.jpg’ or ‘…/filename.jpg’ and the like
$absolute_path = ‘/home/username/path/filename.jpg’;
$real_absolute_path = realpath($absolute_path);

$real_absolute_path should be /home/.glob/username/path/filename.jpg

$filename = ‘filename.jpg’;
$images_path = realpath(’/home/username/images’);
$image_path = $images_path . ‘/’ . $filename;
if (file_exists($image_path)) {
$exif = exif_read_data($image_path);
}

:cool: openvein.org -//- One-time [color=#6600CC]$50.00 discount[/color] on [color=#0000CC]DreamHost[/color] plans: Use ATROPOS7


#6

I now have the file foo.JPG in the root of my DH account (/home//edalzell) and I get the same error.

Can you guys try with my image (http://thedalzells.org/foo.JPG)?

Thanks.


#7

There’s certainly that probability! :slight_smile:

You are correct that I had completely forgotten to consider the .glob link issue. It also appears that I don’t understand at all what the actual problem is (which is probably par for the course for me, because I “programs a bit”, but I am not a programmer!)

I integrated your code into my test case, and, to the degree that understand what exif_read_data is supposed to do, it seems to work for me:

[code]<?php

echo "

From php.net example code:
";
echo “pantheon.jpg:
\n”;

echo ‘
’;
$exif = exif_read_data(‘pantheon.jpg’, ‘IFD0’);

echo $exif===false ? “No header data found.
\n” : "Image contains

headers
\n";

$exif = exif_read_data(‘pantheon.jpg’, 0, true);

echo “pantheon.jpg:
\n”;

foreach ($exif as $key => $section) {

foreach ($section as $name => $val) {

echo “$key.$name: $val
\n”;

}

}
echo "

From Atropos7 code:
";
$relative_path = ‘./coliseum.jpg’; # or ‘./filename.jpg’ or ‘…/filename.jpg’ and the like
$absolute_path = ‘/home/username/domain.tld/coliseum.jpg’;
$real_absolute_path = realpath($absolute_path);

$real_absolute_path should be /home/.glob/username/path/filename.jpg

$filename = ‘coliseum.jpg’;
$images_path = realpath(’/home/username/domain.tld’);
$image_path = $images_path . ‘/’ . $filename;
if (file_exists($image_path)) {
$exif = exif_read_data($image_path, 0, true);
}
echo “
”;
foreach ($exif as $key => $section) {

foreach ($section as $name => $val) {

echo “$key.$name: $val
\n”;

}
}

?>

[/code]The output can be seen at here (note that I didn’t bother with sorting the scrambled maker note stuff). I guess I just don’t grok the problem yet … but then again, I can indeed be slow at times.

–rlparker


#8

I plugged your image into my test file, and put it up for you to see the output (check here).

It looks to me like the function is having a problem reading the exif data from the file; I’m wondering if quicktime might have borked it up a bit?

Have you tried your code with different images?

–rlparker


#9

Interesting…I use a script to resize the images before uploading them. Let me try with the original image.


#10

So with an original image, I don’t get any errors, but I get really funky results. See http://thedalzells.org/gallery/foo/.

Thanks


#11

And if I use GraphicConverter and not Preview to scale the images, it works fine.

Interesting little problem.


#12

Well there ya go! It seems that certain editors/processors might be munging the exif data that the read_exif_data function is expecting to find.

It is an interesting problem, and I’m glad that you have, at least, found a work-around that will you proceed with what you want to do! :slight_smile:

–rlparker


#13

Well, it doesn’t really, as GC can’t be automated in any useful way. Which is why I switched to Preview. Darn.

I was reading on Apple’s discussion list and they are talking about how Canon malforms the EXIF.

So, I will continue to investigate.


#14

Yep! It could very well be a Canon issue. That sucks, as there probably is not an “easy” way to fix it.

–rlparker