Generating URL Thumbnails with ColdFusion and Girafa

So this is yet another blog entry related to something I saw on Dzone. Olaf, a developer from the Netherlands, created a simple PHP script that would integrate with Girafa.com to create URL thumbnails. Girafa has a free account for people who will generate less than 2000 thumbnails per day. So first - sign up with Girafa. If they are as quick with you as they were with me, you will be confirmed in less than an hour. Once you are confirmed you will have a client ID and a signature ID. At that point you can use this simple UDF, modeled after Olaf’s version, to generate a URL for the thumbnail:

<cfscript> function getThumbnailURL(theURL) { var client_id = "CHANGE THIS"; var signature = "CHANGE THIS TOO BUDDY"; var concat = signature & theURL; var mdhash = lcase(hash(concat)); var result = "http://scst.srv.girafa.com/srv/i?i="; signature = mid(mdhash, 17, 16); theURL = urlEncodedFormat(theURL);

result = result & client_id & "&r=" & theURL & "&s=" & signature;
return result; } &lt;/cfscript&gt; </code>

Then to create the thumbnail, simply pass the URL to the UDF:

<cfoutput> <img src="#getThumbnailURL('http://www.cnn.com')#"> <p> <img src="#getThumbnailURL('http://ray.camdenfamily.com')#"> </cfoutput>

Pretty simple. As Olaf mentions, if you need more than 2000 thumbnails, or if you want to simply cache the result, you can store the image locally. (Although that may be against Girafa’s TOS.) As an example of how the thumbsnails look, here is the thumbnail from my blog:

Raymond Camden's Picture

About Raymond Camden

Raymond is a developer advocate. He focuses on JavaScript, serverless and enterprise cat demos. If you like this article, please consider visiting my Amazon Wishlist or donating via PayPal to show your support. You can even buy me a coffee!

Lafayette, LA https://www.raymondcamden.com

Comments