Wish List

My Amazon.com Wish List

Tags

adobe air ajax cf community cfml coldfusion examples ext flex javascript max2007 misc programming technology ui

Recent Entries

One Bourbon, One Scotch and One Beer
Getting Closures: The Groovy Way
Adobe Photoshop Elements 7 Announced
Getting Started with Flex 3
Adobe Munich Sponsors Girl Geek Dinner

Currently Reading


Search

RSS


Subscribe

Enter your email address to subscribe to this blog.

Blogroll

An Architect's View
Ben Forta
CFSilence
Coldfusion Jedi
Rey Bango
TalkingTree



CFIMAGE Part 2

In my previous post CFIMAGE Part 1 we created a simple image and added some text to the image and wrote it out directly to the browser.

In this post we will look at the EXIF data of an image. Typically the EXIF or Exchangeable Image File Format gets written to an image mostly during the creation process of modern digital cameras and only with JPEG images. Some additional information may get written to the image during post processing in Photoshop or other imaging software.

When you upload an image to a service such a Flickr the EXIF data gets stored along and is made available to viewers of your image.

With the inclusion of this tag we now have access to the data ourselves and can likewise use the info in our own photo album applications for example.

It's relatively simple to use, you need to first read in your image using either the cfimage tag or the ImageNew function and then call the ImageGetExitMetadata function.

I'm using one of my favorite photos from our trip to the Tuscany region of Italy in 2006.

<cfimage source="wineCasks.jpg" name="MyImage"/>
<cfset exifData = ImageGetExifMetaData(MyImage)/>
<cfdump var="#exifData#"/>

Produces a dump similar to the following:

The ImageThe EXIF Data
Wine casks


Thats a lot of information packed into the JPEG file!

What I find great about the information, being an amateur photographer, is that you have easy access to things such as F-stop, ISO speed, Focal length, and the exact time you took the image. Most of the time I forget what the F-stop or exact Focal length at which I took the image. A sign of a real amateur no doubt!

You can also get just a single EXIF tag's information using the ImageGetExifTag function for example.

<cfimage source="wineCasks.jpg" name="MyImage"/>
<cfset EXIFFocal= ImageGetExifTag(MyImage,"Focal Length")/>
<cfoutput>#EXIFFocal#</cfoutput>

Would result in 85,0 mm being written out to the browser.

Happy Coding....

Related Blog Entries

Comments
Steven Erat's Gravatar Interesting that the focal length value delimits the decimal places with a comma instead of a zero. Are you using an English locale such as en_US (which should use a period) or perhaps a European locale where a comma would be standard usage for this?

Nikon and Canon dSLRs typically have RAW and JPG capture formats, and EXIF is written to each format. If you use something such as Adobe Lightroom or Bridge CS3 (it comes with Photoshop CS3) then during the initial import of photos from your Compact Flash card to your computer you can automatically apply a preset template of your preferred IPTC data, this way all images could immediately be given basic IPTC data such as Author, Author email/website, and Copyright Notice.
# Posted By Steven Erat | 8/8/07 11:55 AM
Gary Gilbert's Gravatar @Steve,

Yes I am using a European locale, as I am based in Munich Germany (I will have to switch my home computer back to US thank for point that out :) ).

Thanks for the tip on applying IPTC. Unfortunately I can't afford a copy of CS3 or Lightroom (my trial version ran out ) So I am stuck to doing it the old way
# Posted By Gary Gilbert | 8/8/07 12:28 PM
Tomas Fjetland's Gravatar Well, you can also use one of the many free tools out there for working with exif and iptc data. The excellent - nay - incredible EXIFTool ( http://www.sno.phy.queensu.ca/~phil/exiftool/index... ) will let you do this in batch quite easily. It also provides an amazing insight into some of the exif details most other (including CF) list as "Unknown tag", including the model of lens used in many cases. A worthy supplement to the great new image functionality in CF8.
# Posted By Tomas Fjetland | 8/10/07 11:58 AM
Sveinbjorn's Gravatar Thanks for spread the CF wisdom :)
I just installed CF8 and ImageGetExifMetaData works fine.
Where can I get the complete list of the names behind the struct?
Example:
<cfimage source="IMG_0724.JPG" name="MyImage"/>
<cfset exifData = ImageGetExifMetaData(MyImage)/>

<cfoutput>
Model: #exifData.model#<br />
Orientation: #exifData.Orientation#<br />
Date/Time Orginal: #exifData.?!?!#
Exif Image Height: #exifData.?!?!#
etc.
</cfoutput>
# Posted By Sveinbjorn | 11/11/07 4:25 AM
Gary Gilbert's Gravatar Im not sure where you can get a complete list of all the exif tags that are available but you can get a pretty comprehensive list of tags at http://www.sno.phy.queensu.ca/~phil/exiftool/TagNa...
# Posted By Gary Gilbert | 11/12/07 3:31 AM