|
Viewing By Entry / Main
18 Jul. 2007
New in ColdFusion 8 is the cfimage tag and several functions specific to metadata contained in digital images. Here are some basic examples on how to the new ColdFusion 8 Exif and IPTC tags for digital photos, also several things to be careful about when using these tags. ColdFusion 8 now has tags for getting Exif and IPTC metadata directly from your digital photos. The new tags are:
So what are EXIF and IPTC? Exif metadata is the information in a digital image that describes the settings of the camera that took the photo. For example 'Shutter speed', 'aperature', and 'ISO'. Exif data is added to the digital image by a camera when the photo is taken.
How are these tags used?Example of getting all Exif Metadata from a digital image: <cfimage action="read" source="IMG_7654.JPG" name="myImage" />
Output:
Example of how to display an individual Exif tag: <cfimage action="read" source="IMG_7654.JPG" name="myImage" />Output: Canon 30D
Example of getting all IPTC Metadata from a digital image: <cfimage action="read" name="myImage" source="img_7654.jpg"> In this case the IPTC data was added using Adobe Bridge, I labeled the fields as they are labeled in Bridge. This will show that that the IPTC tag names don't always match the tags in the tool the author used to add them. Adobe Bridge (CS2) has 30 IPTC fields, ColdFusion only retrieves 19 of them: Output:
Some things to be careful/aware about:
Retrieving individual Exif tagsKeep in mind that not all images have Exif/IPTC metadata, and if they do have metadata the tags may be different from camera to camera. A digital photo that has been manipulated/re-saved/re-sized/etc may very likely have lost its metadata. Also different digital cameras use different names for tags. Using ImageGetEXIFTag() can cause problems if you are looking for a tag that doesn't exist in the image:
Erroring code: Will cause error: " Variable BADTAGNAME is undefined." One solution to this: <cfif isdefined('badTagName')> Another solution to get around not knowing if certain Exif tags exist is to use ImageGetExifMetadata(): <cfimage action="read" source="IMG_7654.JPG" name="myImage" />
Exif Date IssuesMost Exif Date/Time stamps are stored in a format that is not a valid ColdFusion date (that can be converted from a string). So to evaluate or dateFormat() an Exif date you may have to do a replace() or regex to format the date for CF. Sample code to retrieve the date and time a digital photo was taken: <cfimage action="read" source="IMG_7654.JPG" name="myImage" />Output: 2005:12:28 12:20:32
Comments
Great info! Thanks for the time you spent preparing this!
|