Reading Embedded XMP Packets using ColdFusion

In working more and more on our Digital Asset Management initiatives, I've become more involved in working with XMP.  Mostly as an experiment, I wanted to see if I could read and write this embedded metadata from and to a file.  The Adobe XMP Toolkit indicates how this can be done based on the structure of specific types of files.  It also indicates that packet scanning techniques can be used when file structure is unknown, however, is not encouraged. 

I recognize it might not be the BEST way to read the XMP packet, however, all is fair in love and ColdFusion experimentation :)  It's important to note that this code looks only for the FIRST instance of the string <x:xmpmeta and if there are multiple instances of XMP packets, subsequent instances are ignored.  Adobe also indicates that if there are multiple packets, there is no way to know which packet is the correct one.

Needless to say, using the code below, I was able to read and parse XMP packets from all the Adobe sample files included in their toolkit.  It may not be the end-all solution, and may not work for writing back to the file, but it's a start!

<cfparam name="URL.source" default="xmp-asset.jpg">
<cffile action="readbinary" file="#ExpandPath(URL.source)#" variable="data">
<!--- encode the binary data to hex --->
<cfset hex_data = BinaryEncode(data,"hex") />
<!--- string indicating beginning of packet '<x:xmpmeta' --->
<cfset xmp_string_begin = "3C783A786D706D657461" />
<!--- string indicating end of packet '</x:xmpmeta>' --->
<cfset xmp_string_end = "3C2F783A786D706D6574613E" />
<!--- find the starting index in the hex string --->
<cfset idx_start = FindNoCase(xmp_string_begin,hex_data) />
<!--- find the ending index in the hex string --->
<cfset idx_end = FindNoCase(xmp_string_end,hex_data,idx_start) + Len(xmp_string_end) />
<!--- using the start and end indices, extract the xmp packet --->
<cfset xmp_hex = Mid(hex_data,idx_start,Evaluate(idx_end-idx_start)) />
<!--- convert the hex to readable characters --->
<cfset xmp_string = ToString(BinaryDecode(xmp_hex,"hex")) />
<!--- parse the xml string to and xml structure --->
<cfset xmp_xml = XmlParse(xmp_string) />
<cfcontent type="text/xml">
<cfoutput>#xmp_string#</cfoutput>

Be sure to check out the Adobe XMP Developer Center for more information.

gpuds framework: reflections on my software developer life cycle

On my last trip out to LA for work, I spent some time on the plane brainstorming on the data model and abstraction for gpuds.  I basically want to take the core feature set in the current incarnation of gpuds and abstract it into a "real" ColdFusion application.

I'm starting to realize that most of the ColdFusion development I've done in my career, starting back with CF 4.5 (I think), hasn't really evolved with the evolution of ColdFusion itself.  I'm still writing html/page based apps that require a lot of tedious maintenance and aren't very scalable.  In working more and more with BlogCFC and Mango Blog, I'm realizing some of benefits of CF 7 and 8. 

I think that I knew all along, in theory, how great CFMX was, but never from a practical perspective until I started working on the gpuds framework.  I can't even remember when CFCs were introduced, but aside from facilitating communication from the Flash player to the server, I think I've really been ignorant on why they are so important.

I don't think my applications were ever bad, but they could have been better.  The nature of ColdFusion as a Rapid Application Development platform is what perpetuated my continual use of less-than-efficient application design.  My applications worked and I could crank them out quickly, so why would I bother with any other approach or even framework?

I also think the fact that I'm doing much less development now and more project management is why I'm able to see these things.  I always had a deadline or projects piling up, leaving little time for analysis or post-mortem.  Now that I see these things from a different perspective, I can see all the shortcomings of my approach.

It's amazing to me that I've "discovered" all this in just the scope of working on my gpuds framework, especially considering that I've only just begun!

CFML: Moving ColdFusion Forward

Ben Forta wrote a very interesting blog the other day about the newly created CFML Language Advisory Committee.  This post is great for two reasons.  One, it outlines how this new committee will hopefully benefit CFML in and amongst the ColdFusion community in the long run.  Two, he comments on how and why opening a language up to a community can impact that community in both positive and negative ways, not just on CFML. 

 

A great read for any developer.

gpuds framework: planning stages

Lately I've been thinking about taking my personal photo sharing website and creating a open-source framework version of it.  Why would I bother wasting time on this when sites like Flickr, Snapfish and Photobucket exist?  I feel as if they are still lacking many features that photo sites should include, like original high-resolution file downloads and group file uploading into the same album.  To me it only makes sense.  Say you're at a family reunion and everyone is taking pictures.  What sense does it make for everyone to have their own photo albums on different sites, with pictures of the same thing?

Additionally, I've had a couple people ask me if they can have their own version of gpuds to put on a site for themselves.  I've spent a decent amount of time lately looking at open-source blogging software like Mango Blog and BlogCFC, I thought I'd take a shot at developing something myself for photo sharing since I already have done a lot of the work in the form of gpuds.

BlogCFC was created by Raymond Camden. This blog is running version 5.9.002. genuinejd.com