<?xml version="1.0" encoding="utf-8"?>
			
			<rss version="2.0">
			<channel>
			<title>David Harris&apos;s Technology Blog - JpgMetadataReader</title>
			<link>http://www.harrisfamily.net.nz/devblog/index.cfm</link>
			<description>ColdFusion, Flex and the Universe...</description>
			<language>en-us</language>
			<pubDate>Wed, 08 Sep 2010 06:32:16 -0500</pubDate>
			<lastBuildDate>Sun, 07 Jan 2007 16:07:00 -0500</lastBuildDate>
			<generator>BlogCFC</generator>
			<docs>http://blogs.law.harvard.edu/tech/rss</docs>
			<managingEditor>harrisfamily.net.nz@gmail.com</managingEditor>
			<webMaster>harrisfamily.net.nz@gmail.com</webMaster>
			
			<item>
				<title>Introducing JpgMetadataReader.cfc V0.3</title>
				<link>http://www.harrisfamily.net.nz/devblog/index.cfm/2007/1/7/Introducing-JpgMetadataReadercfc-V03</link>
				<description>
				
				another update so soon you ask?

The main difference with this version is I removed the getter and setter functions for ITPC metadata and created the functions:

- getMetadataKeys( type )
- setMetadataKeys( type , keys )

Why did I do this?

Because every digital camera stores some type of it&apos;s own meta data. To get access to this you can call:
&lt;code&gt;
&lt;cfset stMetaData	= oMetaData.getMetaDataStruct(&quot;C:\path\to\jpg\picture.jpg&quot;,&quot;FujiFilm Makernote&quot;)&gt;
&lt;/code&gt;
...no prizes for guessing the make of digital camera I have!...

So what you can do is set the default keys (to empty string) like this:
&lt;code&gt;
&lt;cfset oMetaData.setMetadataKeys(&quot;FujiFilm Makernote&quot;,&quot;valueone,valuetwo,valuethree&quot;)&gt;
&lt;/code&gt;

That way you don&apos;t need to worry about lots of &quot;structKeyExists&quot; calls! :-)

Hope this makes sense, and any feed back will be welcomed! 
				</description>
				
				<category>JpgMetadataReader</category>				
				
				<category>OpenSource</category>				
				
				<category>ColdFusion</category>				
				
				<pubDate>Sun, 07 Jan 2007 16:07:00 -0500</pubDate>
				<guid>http://www.harrisfamily.net.nz/devblog/index.cfm/2007/1/7/Introducing-JpgMetadataReadercfc-V03</guid>
				
				<enclosure url="http://www.harrisfamily.net.nz/devblog/enclosures/JpgMetadataReaderV0.3.zip" length="1601" type="application/unknown"/>
				
			</item>
			
			<item>
				<title>Introducing JpgMetadataReader.cfc V0.2</title>
				<link>http://www.harrisfamily.net.nz/devblog/index.cfm/2007/1/5/Introducing-JpgMetadataReadercfc-V02</link>
				<description>
				
				Just when you think you are being clever, you find there is someone who has already been cleverer (is that a word?) than you!

I asked Mr Google about ColdFusion and EXIF and he told me about this: &lt;a href=&quot;http://www.leavethatthingalone.com/blog/index.cfm/2006/5/16/Using-ColdFusion-to-Read-EXIF-Information-from-JPEGs&quot; target=&quot;_blank&quot;&gt;http://www.leavethatthingalone.com/blog/index.cfm/2006/5/16/Using-ColdFusion-to-Read-EXIF-Information-from-JPEGs&lt;/a&gt;

The same Java class was being used, but the really clever thing here is that you don&apos;t need to add that class to the lib dir/class paths in CF.

After reading this, and thinking how I plan to use my JpgMetadataReader.cfc, I have made to following changes:

- the init function now has the optional argument &quot;JpegMetadataReader&quot;, which is &quot;An instantiated object of com.drew.imaging.jpeg.JpegMetadataReader&quot; (that&apos;s the hint)
If you do not pass this in, it will attempt to create the java object, and if it is located in the lib/class path, you&apos;ll be fine :-)

- added the functions &quot;getITPCKeys&quot; and &quot;setITPCKeys&quot;. These functions are used to define a comma delimited list of keys that MUST be returned in the result struct.
The struct keys are inited with a value of &quot;&quot; (empty string)
The default list is &quot;Caption/Abstract,Keywords,Credit,Copyright Notice,Object Name&quot; and is dirived from &lt;a href=&quot;http://www.controlledvocabulary.com/imagedatabases/iptc_naa.html#IPTCchart&quot; target=&quot;_blank&quot;&gt;http://www.controlledvocabulary.com/imagedatabases/iptc_naa.html#IPTCchart&lt;/a&gt;

- added the optional argument &quot;type&quot; to &quot;getMetaDataStruct&quot;.
This will return only the type of meta data you specify.
eg: &lt;code&gt;
&lt;cfset stMetaData	= oMetaData.getMetaDataStruct(&quot;c:\my\picture\here.jpg&quot;,&quot;exif&quot;)&gt;
&lt;/code&gt;
...will only return &quot;exif&quot; meta data. If this argument is not provided or is an empty string, any avalible meta data will be returned.
If a non-existant type is provided, you will end up with a empty Struct. 

So, enough info, now for some code:

&lt;code&gt;
&lt;!---
...code here to create the java object...

eg: 
MyJpegMetadataReaderJavaObject = loader.create(&quot;com.drew.imaging.jpeg.JpegMetadataReader&quot;);

...if you are using Mark Mandle&apos;s Java loader (http://javaloader.riaforge.org/)

---&gt;

&lt;cfset oMetaData	= createObject(&quot;component&quot;,&quot;org.harris.JpgMetadataReader&quot;).init(MyJpegMetadataReaderJavaObject)&gt;

&lt;cfset stMetaData	= oMetaData.getMetaDataStruct(&quot;c:\my\picture\here.jpg&quot;)&gt;

&lt;cfdump var=&quot;#stMetaData#&quot;&gt;

&lt;/code&gt;

The only difference here from the initial code snippet is that I have provided the Java class &quot;com.drew.imaging.jpeg.JpegMetadataReader&quot; in the variable &quot;MyJpegMetadataReaderJavaObject&quot;

What is really cool about the JavaLoader is that you can load ANY java class!

Enjoy! 
				</description>
				
				<category>JpgMetadataReader</category>				
				
				<category>OpenSource</category>				
				
				<category>ColdFusion</category>				
				
				<pubDate>Fri, 05 Jan 2007 17:57:00 -0500</pubDate>
				<guid>http://www.harrisfamily.net.nz/devblog/index.cfm/2007/1/5/Introducing-JpgMetadataReadercfc-V02</guid>
				
				<enclosure url="http://www.harrisfamily.net.nz/devblog/enclosures/JpgMetadataReaderV0.2.zip" length="1402" type="application/x-zip-compressed"/>
				
			</item>
			
			<item>
				<title>Introducing JpgMetadataReader.cfc</title>
				<link>http://www.harrisfamily.net.nz/devblog/index.cfm/2006/12/29/Introducing-JpgMetadataReadercfc</link>
				<description>
				
				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 &lt;a href=&quot;http://en.wikipedia.org/wiki/IPTC&quot; target=&quot;_blank&quot;&gt;here&lt;/a&gt;
The one I was most interested in was the &quot;Caption&quot;, 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 &lt;a href=&quot;http://www.airtightinteractive.com/simpleviewer/&quot; target=&quot;_blank&quot;&gt;Simple Viewer&lt;/a&gt;)
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 &lt;a href=&quot;http://en.wikipedia.org/wiki/EXIF&quot; target=&quot;_blank&quot;&gt;here&lt;/a&gt;)

There are 2 programs I use to set this meta data up, both are free (of course!)

- IrfanView (with all the plugins installed) &lt;a href=&quot;http://www.irfanview.net/&quot; target=&quot;_blank&quot;&gt;http://www.irfanview.net/&lt;/a&gt;
- PixVue, which gives a nifty right click menu to add/edit the meta data. &lt;a href=&quot;http://www.pixvue.com/&quot; target=&quot;_blank&quot;&gt;http://www.pixvue.com/&lt;/a&gt;

This CFC uses the Java class metadata-extractor-2.3.1.jar, which you can download from: &lt;a href=&quot;http://drewnoakes.com/code/exif/releases/&quot; target=&quot;_blank&quot;&gt;http://drewnoakes.com/code/exif/releases/&lt;/a&gt;
You will need to put this in the ColdFusion &quot;lib&quot; directory and restart the ColdFusion instance.

Right, now for some code...

&lt;code&gt;
&lt;cfset oMetaData	= createObject(&quot;component&quot;,&quot;JpgMetadataReader&quot;).init()&gt;

&lt;cfset stMetaData	= oMetaData.getMetaDataStruct(&quot;\path\to\my\picture.jpg&quot;)&gt;

&lt;cfdump var=&quot;#stMetaData#&quot;&gt;
&lt;/code&gt;

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&apos;s all I use...), but feel free to have a look at it use it!

If you find it really useful consider donating to &lt;a href=&quot;http://drewnoakes.com/code/exif/releases/&quot; target=&quot;_blank&quot;&gt;http://drewnoakes.com/code/exif/releases/&lt;/a&gt;, as he did all the really hard work!

...in the mean time, this&apos;ll work fine until CF8 comes out with all this native built in! 
				</description>
				
				<category>JpgMetadataReader</category>				
				
				<category>ColdFusion</category>				
				
				<pubDate>Fri, 29 Dec 2006 17:51:00 -0500</pubDate>
				<guid>http://www.harrisfamily.net.nz/devblog/index.cfm/2006/12/29/Introducing-JpgMetadataReadercfc</guid>
				
				<enclosure url="http://www.harrisfamily.net.nz/devblog/enclosures/JpgMetadataReader.zip" length="1241" type="application/x-zip-compressed"/>
				
			</item>
			</channel></rss>