Alright, getting a little lost in the documentation and forums between various functions and methods to get EXIF vs IPTC vs internal data and whatnot.
Basically, I'm looking for a method to get an arbitrary EXIF tag from an image in zenphoto. Right now, specifically, that would be the 'ImageDescription' tag, but the question is more generic.
The tag seems to be represented in the exif.php (exifer), but I'm not quite spotting how to invoke that.
If I use getExifData(), I seem to only get a subset of the exif tags (make, model, various camera settings, etc.
If I use getImageMetaData, then I'm accessing the IPTC information; which is not where the information is stored in my case.
I'm probably missing something obvious, so feel free to just slap me with the URL to the docs
Thanks in advance!
Comments
Exifier itself does not necessarily process all tags so there may be some effort there as well. (If you add tag processing, let us know, we can then indclude them in the distribution.)
For...
http://www.zenphoto.org/documentation/functions/_functions.php.html#functiongetImageMetadata
The description reads that it parses IPTC information, rather than EXIF. This seems to be the case as well, as the only tag collected for my given image is (output of print_r on the array):
Array ( [date] => 2009:06:25 04:10:30 )
( although ExifTool GUI seems to suggest that there's no IPTC data at all )
While for...
http://www.zenphoto.org/documentation/classes/_Image.html#getExifData
The description reads only 'Returns an array of EXIF data'. The output of that is:
Array ( [EXIFOrientation] => [EXIFMake] => Sony [EXIFModel] => DSC-V3 [EXIFExposureTime] => [EXIFFNumber] => [EXIFFocalLength] => [EXIFFocalLength35mm] => [EXIFISOSpeedRatings] => [EXIFDateTimeOriginal] => 2009:06:25 04:10:30 [EXIFExposureBiasValue] => [EXIFMeteringMode] => [EXIFFlash] => [EXIFImageWidth] => [EXIFImageHeight] => [EXIFContrast] => [EXIFSharpness] => [EXIFSaturation] => [EXIFWhiteBalance] => [EXIFSubjectDistance] => [EXIFGPSLatitude] => [EXIFGPSLatitudeRef] => [EXIFGPSLongitude] => [EXIFGPSLongitudeRef] => [EXIFGPSAltitude] => [EXIFGPSAltitudeRef] => )
Which seems to suggest that ImageDescription isn't in the list. Note, however, that I've not yet upgraded to the latest and greatest (installed is 1.2.3 [3427]), so I'll have to grab that and see if it got added; otherwise I suspect I'd have to add it.
Alternatively, just digging a little further, would I have to call read_entry from exif/exif.php manually?
I'll hit the new version first :>
As for the IPTC, we will always get a date from somewhere--if just from the file--so there probably is not any IPTC data.
I don't think any tags have been added recently.
So it seems that something a la..
[code]
$metadata = read_exif_data_protected($_zp_current_image->localpath,0);
echo $metadata['IFD0']['ImageDescription'];
[/code]
..does the trick. Of course this is somewhat wasteful as it always accesses the image file, rather than the database. So my next step is to make things..
[code]read image description from database
|- if empty, read description from file
| |- if empty, write 'No description' etc. per default
| '- if not empty, use read result, and store in database
'- if not empty, use read result[/code]
This way any description in an image is automatically read, and if I want to override it with another description, I can do so using the existing mechanisms.
Hooray *crosses fingers*
`'EXIFDescription' => array('IFD0', 'ImageDescription', gettext('Image Description'), false),`
Let us know how it works. (Or create a ticket and attach an image which has this field set.)
Which might not be so bad for a generic solution, but seems a tad on the wasteful side otherwise... would need the admin page to be updated to show the original description, or radiobuttons to show no/one/other/both descriptions, etc.?
It takes only a little more code to populate the title of the image from that field. (BTW, the EXIF 2.2. specification labels this field as "Image Title" even though it is tagged as ImageDescription.)
Anyway, I've added this in the nightly build. It populates the title. Also added Copyright Holder and Artist since these seemed possibly useful. The latter are just available as imageMetadata fields.
One word of warning.. I just noticed that my camera actually fills in the ImageDescription field, by default, with 31 space characters. Exifer sees this as perfectly valid data, but I'd wager it's not typically what a user might want to have displayed. I added a preg_match("/\S/",$exifdesc) in my own code to check for any non-space characters before allowing it as a valid description (rather than title).
yeah, I'm going against the spec... heck, the spec goes against the spec, really.. ImageDescription is the tag name, the spec says this is supposed to be the title, but obviously the tag name suggests otherwise.. on top of that, the spec specifies a maximum of 999 characters for it. A 999-character title? really? :>
I do agree that zenphoto out-of-the-box should respect the spec, though.
Thankfully zenphoto is easy enough to modify, which is why I chose to go with it (I run another gallery on the same domain for somebody else, using Gallery2... I can't make heads nor tails of that thing). Speaking of which, 'bout time I hit that Donate button
Thanks again!