Test & Validate Exif Data
Okay. A case of beer up for grabs for the first person to get this one (you have to come to Johannesburg to get it though!)
I have to write an application that extracts EXIF data from photographs uploaded to the server and stores it in a database. So I try the following:
<cfimage action="read" source="#file.serverfile#" name="image" />
<cfset exif = ImageGetEXIFMetaData(image)>
<cfdump var="#exif#">
<cfquery name="yadda" datasource="#dsn">
insert into pics (focal_length) values (#focallength#) where yadda yadda fishpaste.
</cfquery>
Problem solved, right? Wrong! The dump file gives me a bunch of variables like "Exposure Time" and "Max Aperture Value". (note the spaces). I need to isolate that "exposure time" and "Max Aperture Value" variables.
<cfset focallength = ImageGetExifTag(image,"Focal Length") />
<cfoutput>#focallength#</cfoutput>
Whoo hoo!
But now, what if some malicious idiot uploads a file WITHOUT exif data? OOPS! This is where I get stuck - how do I test for the variable? How do I test if that variable exists? Easy enough to do without spaces. How do I do it WITH that space between "focal" and "length"? I've "isdefined" my way from hell to breakfast, without any luck!
PS: its late, I'm tired, and had three beers already!
Spank you in advance. Now go out and conquer!