Opened 17 years ago
Closed 17 years ago
#5162 closed enhancement (fixed)
Extract additional image metadata from EXIF/IPTC
Reported by: | tellyworth | Owned by: | ryan |
---|---|---|---|
Milestone: | 2.5 | Priority: | normal |
Severity: | normal | Version: | |
Component: | General | Keywords: | |
Focuses: | Cc: |
Description
The included patch extracts EXIF and IPTC metadata from uploaded files and stores it in the attachment metadata. The additional metadata may be used by plugins or future features (photoblogging in particular).
Currently it stores 10 fields: aperture, credit, camera (model), caption, created_timestamp, copyright, focal_length, iso, shutter_speed and title. I selected these because they're likely to be useful, and are easy to extract (I don't think it's desirable to store every EXIF field as most will never be used).
The code as submitted here uses PHP's built-in EXIF and IPTC functions. PHP's EXIF functions have some shortcomings and aren't always available, so it would make sense to expand it to use external EXIF libraries where available (Exifer, PEL).
The only place the extra image metadata is displayed at present is on the Manage/Uploads/Edit tab. It's a bit rough, intended mainly for testing.
Plugins and other code can access the image metadata using the regular metadata api, like so:
$meta = wp_get_attachment_metadata( $id ); echo "Caption: " . $meta['image_meta']['caption'];
Attachments (2)
Change History (12)
#3
@
17 years ago
+1 to the idea.
Some comments on the code:
It would be nice for the relationship between EXIF data tag and name was stored in an array and looped over to load the data - this array should be filtered to allow plugins a way of easily adding extra EXIF fields (or removing ones it doesn't want loaded)
We would need a similar way for filtering the list to be displayed as well - that would want a relationship between the human-readable field name and the translateable string.
#4
@
17 years ago
I thought about iterating through an array of keys, but EXIF data tends to be ad-hoc and sometimes requires special handling for each field.
A filter is a good idea. The plugin could worry about output translation.
#5
@
17 years ago
wp-exif-r6201a.patch calls a filter on the $meta array before returning it. It passes the file name so filters can read additional info from the file if necessary.
#9
@
17 years ago
- Resolution fixed deleted
- Status changed from closed to reopened
Request to extend EXIF parser to include GPS metadata keys stored in EXIF/IPTC.
Reference projects are available in relation to PHP, the PHP EXIF Library, and use with WordPress (and web mapping applications).
One example of such project that appears to already have dealt with various camera models' approach to GPS in metadata is the following. This project appears to be as a WordPress related development.:
PHP Exif-Parser
I neglected to mention: unit tests for the wp_read_image_metadata() function are in http://svn.automattic.com/wordpress-tests/wp-testcase/test_image.php.