ColdFusion 8's image functions + jQuery= a UI for adding text and color blocks into an image file
One of the new features in ColdFusion 8 is the ability to manipulate images using ColdFusion tags and functions. In addition to being to do generic image manipulations (like rotating, resizing, and cropping), you can also add text to an image using the ImageDrawText function, like in this example:
<!---Assign the image file to the carImage variable--->
<cfimage name = "carImage" action="read" source="ferrari.gif"/>
<!---Add the text "Fast car!" to the image and place it 10 pixels from the left and 15 from the top--->
<cfset ImageDrawText(carImage, "Fast car!, 10, 15)>
<!---Display the new image--->
<cfimage source="#carImage#" action="writeToBrowser">
A week ago, an idea popped into my head: "What if you could create a UI tool that would let a user decide what text should appear on the image and where it should appear?"
I decided to try and answer that question. The result: a working proof-of-concept application that lets you add text and blocks of color anywhere on a selected image using a UI tool powered by jQuery JavaScript functions. When you're done manipulating the image, you submit the data defining your changes to ColdFusion via an AJAX call, and ColdFusion creates a new image in temp space based on that data and displays it. You can save the new image down to your computer or store the data you submitted in the database so the image you made can be reproduced without permanently storing a new image file.
The fact that it only took me a week to do this (no more than 25 hours) is a testament to both the power and simplicity of ColdFusion and jQuery.
You can try out the proof-of-concept at: http://www.swartzfager.org/captionator.
- Login or register to post comments
- 2842 reads
- Printer-friendly version
(Note: Opinions expressed in this article and its replies are the opinions of their respective authors and not those of DZone, Inc.)










Comments
Boyan Kostadinov replied on Mon, 2008/03/03 - 4:52pm
anu replied on Fri, 2008/04/11 - 10:45am