Getting EXIF Metadata with ColdFusion 8
October 26, 2007
One example that I've been meaning to post is how to get Image Metadata using the Exchangeable Image File Format or EXIF a using ColdFusion 8. It's actually quite simple, to get a list of all the EXIF tags simply use the
Here's a quick example:
<cfimage action="read" source="#ExpandPath("lobster.jpg")#" name="img">
<cfset exif = ImageGetEXIFMetaData(img)>
Here's a screen shot of a CFDUMP of the EXIF Image Metadata.
As you can see some of the useful keys are
Model which gives you the digital camera model (Canon EOS DIGITAL REBEL XTi in this example),
Make gives you the digital camera brand (Canon),
Exposure Time gives you the exposure time (1/60 sec).
Trackback Address: 657/3783A6B1BE0BBBA0B6684048CFC5334C
You should change the Color Space setting on your camera from sRGB to AdobeRGB to capture color differentials at a higher resolution.
Thanks for the Tip Steven! The photo I was using was actually taken by my sister in-law on her camera. I will let her know though.
Wow, great post. I had no idea CF8 had a way to extract EXIF data. Thanks!!
Pete in CF 8.1 I am getting zero data returned. Did they change something or is there something I have to do before playing with ImageGetEXIFMetaData?
@Dan - EXIF still works in CF 8.1, not all images provide EXIF data, so that would be the first thing I would check.
Second you might also want to install the hotfix for CF 8.1 as it includes some image manipulation bugs.
If the file does have valid EXIF data, and CF 8.1 can't read it, you should submit a bug to Adobe.
Is there any way to remove EXIF data before saving an image? Thumbnail for ~2.5Kb can weight ~205Kb just because of EXIF, which is useless in this case.
Hi Pete and thanks for this article.
How can I get the Date/Time out of exif? There is no problem e.g. getting the model info like this: <cfoutput> #exif.model# </cfoutput> But where can I get the "name" for all the Date/Time functions?
<cfoutput> #ImageGetExifTag(img, "Date/Time Original")# </cfoutput>
I have noticed one thing, we use the User Comment field in the EXIF data and with CF8 it comes back as an empty string. CF9 appears to have corrected the issue and returns the contents of the User Comment field. Looks like I'll have to upgrade.
Really great article with very interesting information. You might want to follow up to this topic!?! 2011
I understand what you mean, but for the pseroups of the Tiobe index do they actually make those same distinctions when analysing other languages? If built-in image manipulation functions are part of the framework and not part of a discussion about the programming language that they belong to then similarly every C# article that mentions a native package or Windows API should be excluded from the index but I highly doubt they are excluded. But this isn't really my point When someone talks about ORM in ColdFusion 9, interfaces in ColdFusion 8, or CFC-based custom tags in Railo they are talking about "the language". All these things would be excluded from the Tiobe index because they are being pointlessly pedantic about the use of the word "ColdFusion" or "Railo" or otherwise. The fact is we all say "ColdFusion" far more than we say "CFML", even when we mean "the language not the application server". Chances are someone at Tiobe just doesn't like ColdFusion and thought it would be funny to only rank it based on "CFML" and "CFScript", and we all fall for it every time.