WordPress.org

Make WordPress Core

Opened 13 years ago

Closed 13 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)

wp-exif-r6201.patch (6.4 KB) - added by tellyworth 13 years ago.
wp-exif-r6201a.patch (6.4 KB) - added by tellyworth 13 years ago.

Download all attachments as: .zip

Change History (12)

#1 @tellyworth
13 years ago

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.

#2 @Otto42
13 years ago

+1 I like this idea.

#3 @westi
13 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 @tellyworth
13 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 @tellyworth
13 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.

#6 @ryan
13 years ago

  • Owner changed from anonymous to ryan

#7 @ryan
13 years ago

  • Milestone changed from 2.5 to 2.4

#8 @ryan
13 years ago

  • Resolution set to fixed
  • Status changed from new to closed

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

#9 @remotesensingtools
13 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

#10 @Viper007Bond
13 years ago

  • Resolution set to fixed
  • Status changed from reopened to closed

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

Note: See TracTickets for help on using tickets.