Browsing Posts in EXIF, XMP and Other Meta-Data

OK, so I have a task. I need to embed data from a database into an image using an XMP layer. Where to start?

Firstly I know a little about metadata embedding. Most are probably familiar with EXIF (EXchangeable Image Format), data that's embedded natively by most modern digital cameras into images. Tapping into EXIF headers will expose a plethora of information about what focal length was used, exposure time, make and model of camera etc... With EXIF class files available for PHP, and even limited native support built into PHP, retrieving and using that data is pretty straightforward.

Then there is IPTC Information Interchange Model or IIM, another layer of meta-data that allows for information to be embedded into various image files. However, for the most part this has now been superseded by Adobe's Extensible Metadata Platform or XMP.

Dealing with XMP in PHP is a little more complicated. In time, I think, you will natively have the ability to interactive with the XMP layer through PHP, at the moment though there doesn't appear to be that ability. PHP does provide the ability to access and manipulate IPTC data through it's iptcembed() and iptcparse() functions, but it seems that newer versions of Photoshop and XMP aware applications do not consider IPTC data authoritative.

XMP is defining the path towards a more semantic web.

[XMP] is an important piece that brings the Semantic Web closer to realization.
- Eric Miller, W3C Semantic Web Activity Lead

You have all this data out there in the ether, but it all comes back to that Charles Babbage philosophy "Garbage In, Garbage Out" GIGO! If you don't meta-tag your data properly you aren't fully enriching a data-retrieval process. How does anyone find it, you have all this great data that isn't being used.

That's what the Dublin Core embraces. If you ever notice DC.publisher in the meta-tags of an HTML document. That's Dublin Core. An initiative to embrace semantics in HTML markup. Dublin Core semantics can also be embedded into XMP, but the great thing about XMP is it allows for personalization of data archival with meta information. Using the Resource Description Framework (RDF) expressed as XML, serialized data can be stored with your digital assets. XMP aware applications such as Photoshop and Portfolio (It's what my company uses and what I'm trying to interact with) can categorize, search and even modify this XMP layer. Suddenly organizing your digital assets took on a whole new level. Metadata goes beyond organizing data into folders or sub-folders, it embeds an encyclopedia of information with the asset itself! No matter where you take that asset, that data will follow.

Back to the subject of XMP in PHP. With Photoshop preferring XMP data over IPTC (naturally. Photoshop is, after all, an Adobe product), I need to be able to successfully manipulate the XMP data layer.

Also, Photoshop now uses XMP for it's primary metadata, meaning IPTC is only read by Photoshop if XMP is not present.
- PHP Community

The great thing about PHP and the open source community is that if you look hard enough, someone, somewhere has written something to tackle your immediate issue. Step-up one Evan Hunter, credit where credit is due. He has done just that in his PHP JPEG Metadata Toolkit, but don't let the title fool you, it works with other image formats as well.

A quick download later, and perusal of his code and it looks good. I'll let you know how I get on and post some updates. If anyone knows of some great PHP/XMP resources let me know!

EXchangeable Image file Format. EXIF data is data that is automatically stored with most pictures taken on today's digital camera's. In most programming languages there are way's to extract this information. In PHP you can use some of the built in EXIF functions, however this requires that exif-support is enabled., but the trouble is it doesn't really return much useful information, most of the information you could retrieve anyway using some of PHP's Image Functions.

So I then began scraping around the Internet looking for some suitable code for extracting more data than the built in PHP functions would give me and came across a PHP library called Exifer 1.5 by Jack Olefsky, this is a very comprehensive library able to extract an amazing array of EXIF data using one simple function call.

$path = SERVERPATH."/albums/".$album."/".$image; 
$verbose = 0; 
$result = read_exif_data_raw($path,$verbose);   


This library will return a complete multi-dimensioned array allowing you to simply pick out the information you want.

<?php echo $result['SubIFD']['MakerNote']['Settings 1']['ExposureMode']; ?>

So if you fancy playing around with EXIF in PHP I'd seriously recommend starting with this PHP library.

... I decided to play around with GeoIP coding, EXIF data manipulation and dynamic image generation in php. Yes, yes... I know... why !? Well, as you all know I work with computers for my sins, spending my days, like many of us slumped behind a keyboard at a desk, and every now and again I'll have a moment of boredom, sit down and tinker with things ...

Computer programming is like any skill really, the more you practice it, the better you get. Anyway... so what the hell is all that I was talking about... GeoIP thinky ma' wha' !?

Well GeoIP coding is simply the abililty to translate your IP address ( a unique number, a bit like a phone number, assigned to every computer in the world ) into a physical, real world, location.

The wonderful people at have made some GeoIP databases freely available online, so I figured I'd download them and try and make something out of it. Tinker around with it. The net result is on the homepage of this site., if it's able to translate your IP address into a real world location you should get a link at the very top of the homepage saying "Welcome from ... " Click on that and it should give you a pretty Google Map. I know... so what !? Well that's the irony of computers, to get it to do something simple usually takes hours of coding. ( And computers save us time how !? )

Next I decided to plug the database into my website statistics monitoring software ( if your interested try this link ) using the built in Perl Modules available in AWStats, but this proved to be an absolute nightmare. So for anyone else out there suffering the same "why the f* is this not working... " problem as I did, I wrote an article here on how to configure AWStats to use the free MaxMind GeoIP services.

Next, dynamic image generation. Why!? Well I was getting fed up of people phishing around on my websites trying to relay SPAM. Fortunately they can't, but I decided to add an extra level of Anti-SPAM'ness to my Contact Forms. You see the internet is full of all sorts of rubbish, including software robots all looking to abuse your nicely written "Contact Me" forms to send out lots and lots of lovely SPAM. Well some wonderful people at Carnegie Mellon University and IBM devised a way to stop this in the form of a CAPTCHA image.

You can usually tell a CAPTCHA image because it'll be a bunch of random digits and numbers you have to enter before submitting a form sometimes. Well I figured why not make this a bit more fun, instead of the boring box of numbers and letters, why not make it a bit more interesting, so I decided to write something for my sisters website here : Everytime you refresh (hit f5 on your keyboard) the page, those numbers change and the image is dynamically generated. Nice ! Personally I just love the cartoon...

Not satisfied with my achievements I moved onto EXIF data. I'd been reading up alot on this the last couple of weeks because I was very interested in outputting some of this data onto my photograph pages here :

All pictures taken with most modern cameras these days automatically store some kind of EXIF information ( or meta-data ). Like weather you used a flash or not, the make and model of the camera etc... Well you may have noticed that on some photography sites all this information is displayed on screen along with the photograph. Well rather than type all this out the boring, long winded way why not do it automatically. So I did.

You can see the results on my photo gallery and my sisters website here :

Ah! and so that was it... like I said... a moment of boredom !