Ticket #5162 (closed enhancement: fixed)

Opened 10 months ago

Last modified 8 months ago

Extract additional image metadata from EXIF/IPTC

Reported by: tellyworth Assigned to: ryan
Priority: normal Milestone: 2.5
Component: General Version:
Severity: normal Keywords:
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

wp-exif-r6201.patch (6.4 kB) - added by tellyworth on 10/08/07 08:26:25.
wp-exif-r6201a.patch (6.4 kB) - added by tellyworth on 10/08/07 10:55:21.

Change History

10/08/07 08:26:25 changed by tellyworth

  • attachment wp-exif-r6201.patch added.

10/08/07 08:27:52 changed by tellyworth

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.

10/08/07 08:29:40 changed by Otto42

+1 I like this idea.

10/08/07 08:40:04 changed by westi

+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.

10/08/07 09:09:01 changed by tellyworth

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.

10/08/07 10:55:21 changed by tellyworth

  • attachment wp-exif-r6201a.patch added.

10/08/07 10:57:22 changed by tellyworth

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.

11/04/07 23:49:07 changed by ryan

  • owner changed from anonymous to ryan.

11/05/07 00:00:44 changed by ryan

  • milestone changed from 2.5 to 2.4.

11/05/07 00:01:27 changed by ryan

  • status changed from new to closed.
  • resolution set to fixed.

(In [6313]) Extract and save image metadata. Props tellyworth. fixes #5162

11/14/07 08:54:51 changed by remotesensingtools

  • status changed from closed to reopened.
  • resolution deleted.

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

11/14/07 10:05:25 changed by Viper007Bond

  • status changed from reopened to closed.
  • resolution set to fixed.

Please open a new ticket rather than reopening this one. ;)