Here is the JpgMetadataReader.cfc, why you would use it and how would use it.
Every JPG has meta data connected to it.
The format I was mainly interested in was IPTC (International Press Telecommunications Council) standard. (more about that here
The one I was most interested in was the "Caption", the idea being you could set this value up, upload the file and it would be available to be use on the sever when displaying it in an album view (in my case Simple Viewer)
What is great about this is that you can assign the comment TO THE JPG, and thus storing the data in a single location, rather than the JPG in one place, and the information about it in another!
Along with the IPTC meta data there is also the EXIF (Exchangeable Image File Format) meta data.
The EXIT meta data has lots of good stuff about when/how/what settings the camera used when the photo was taken. (More about that here)
There are 2 programs I use to set this meta data up, both are free (of course!)
- IrfanView (with all the plugins installed) http://www.irfanview.net/
- PixVue, which gives a nifty right click menu to add/edit the meta data. http://www.pixvue.com/
This CFC uses the Java class metadata-extractor-2.3.1.jar, which you can download from: http://drewnoakes.com/code/exif/releases/
You will need to put this in the ColdFusion "lib" directory and restart the ColdFusion instance.
Right, now for some code...
<cfset oMetaData = createObject("component","JpgMetadataReader").init()>
<cfset stMetaData = oMetaData.getMetaDataStruct("\path\to\my\picture.jpg")>
<cfdump var="#stMetaData#">
This will return ALL meta data to do with the JPG (EXIF, IPTC and any other)
If it is not defined, it does not return it, so you would have to check for it before you attempt to output it...
I have only tested it on WindowsXP running CF7 on JPG files (as that's all I use...), but feel free to have a look at it use it!
If you find it really useful consider donating to http://drewnoakes.com/code/exif/releases/, as he did all the really hard work!
...in the mean time, this'll work fine until CF8 comes out with all this native built in!