Comment from Exif on upload?

phgrove

Joined: 2002-10-10
Posts: 101
Posted: Sat, 2002-11-02 17:24

I have tried to alter the code so that when uplaoding a file with a comment already in the Exif data it would add this as the images caption, however it doesn't seem to work. The code below is what i have added/changed to the save_photos.php file.

msg("- Adding $name");
if ($setCaption) {
$caption = $originalFilename;
} else {

$myExif = array();
$myExif = getExif($newFile);
if ($myExif) {
// following line commented out because we were losing
// comments from the Exif array. This is probably due
// to differences in versions of jhead.
// array_pop($myExif); // get rid of empty element at end
array_shift($myExif); // get rid of file name at beginning
while (list($key, $value) = each ($myExif)) {
if ($key == "Comment") {
$caption = $value;
}
}
} else {
$caption = "";
}
}

However all the $myExif seem to contain is the value array and not the Exif data from the file being uploaded, does anyone have any idea what is wrong?

Peter

 
phgrove

Joined: 2002-10-10
Posts: 101
Posted: Sun, 2002-11-03 12:06

OK got it working. So for anyone else wanting this feature edit the save_photo.php file at line 323 and change it to:-

msg("- Adding $name");
if ($setCaption) {
$caption = $originalFilename;
} else {
list($status, $myExif) = getExif($file);
if ($myExif) {
// following line commented out because we were losing
// comments from the Exif array. This is probably due
// to differences in versions of jhead.
// array_pop($myExif); // get rid of empty element at end
array_shift($myExif); // get rid of file name at beginning
while (list($key, $value) = each ($myExif)) {
if ($key == "Comment") {
$caption = $value;
}
}
} else {
$caption = "";
}
}