Leave That Thing Alone Blog
Using ColdFusion to Read EXIF Information from JPEGs
Update: ColdFusion8 Exif and IPTC
Using Mark Mandel's JavaLoader and Drew Noakes' open source Java based metadata extractor it is possible to read EXIF info from a JPEG without having to have add a "ColdFusion Class Path" in ColdFusion server admin.
Extracting EXIF information out of a JPEG with the metadata extractor library isn't new for ColdFusion, Chris Wigginton demonstrated how to do this several months ago. But in a shared hosting environment setting the class path can be a problem, that's where the JavaLoader helps out by eliminating the need to add a class path.
The below code is an example of iterating through a JPG's EXIF tags using the metadata-extractor loaded with the JavaLoader:
<cfscript>
photo = "#expandPath("yourPhoto.jpg")#";
photoFile = createObject("java","java.io.File").init(photo);
//set the path
paths = ArrayNew(1);
paths[1] = expandPath("metadata-extractor-2.3.1.jar");
//create the loader
loader = createObject("component", "JavaLoader").init(paths);
//create the JpegMetadataReader instace
JpegMetadataReader = loader.create("com.drew.imaging.jpeg.JpegMetadataReader");
//Read jpg file
JpegMetadata = JpegMetadataReader.readMetadata(photoFile);
//get directory iterator
JpegDirectories = jpegMetadata.getDirectoryIterator();
</cfscript>
<!--- output all EXIF info tags --->
<cfoutput>
<cfloop condition="JpegDirectories.hasNext()">
<cfset currentDirectory = JpegDirectories.next() />
<cfset tags = currentDirectory.getTagIterator() />
<table>
<tr>
<th colspan="4">Directory: #currentDirectory.getname()#</th>
</tr>
<cfloop condition="tags.hasNext()">
<cfset currentTag = tags.next()>
<tr>
<td>#currentTag.getTagType()#</td>
<td>#currentTag.getTagName()#</td>
<td>#currentTag.getDescription()#</td>
<td>#currentTag.toString()#</td>
</tr>
</cfloop>
</table>
</cfloop>
</cfoutput>
It is also possible to refer to an individual EXIF tag item this way: #currentDirectory.getString(currentDirectory.TAG_Focal_Length)#
This example code can been seen in action here: Example EXIF output with different input JPGs
To get the above to to work you need to download the JavaLoader.cfc and the metadata-extractor-2.3.1.jar file and place them in the same directory as the example CF code.

Comments
"a descriptor must be set using setDescriptor(...) before descriptions can be provided"