Viewing By Entry / Main
October 25, 2006

I'm sitting in on Prayank Swaroop's Image Manipulation in ColdFusion session right now. It's the last of three sessions on new features/functionality coming out in ColdFusion 8 (Scorpio). Image manipulation is something a LOT of people have been asking for for quite a long time, so it's nice to see it finally being implemented.

The new cfimage tag and over 45 supporting functions will support the following:

  • Creating images
  • Image conversion
  • Thumbnails and resizing
  • JPEG compression
  • Adding text
  • Watermarking
  • Base64 support
  • Captchas
  • Blobs
  • Exif and IPTC (only for JPEG)
  • Basic graphic functions
  • Magic of drawing strokes

<cfimage source="foo.jog" name="myImage" action="read">

<cfset myImage = imageNew("foo.jpg")>

Inputs include URL's, files,

You'll be able to read in all sorts of meta information about images - dimensions, color space, resolution, etc.

Image conversion supports jpg, gif (not animated), png, bmp and tiff. Other formats that can be read/written but have not been tested are FlashPix, etc.

If you're working with jpegs, you can specify the compression rate (0.75 is the default) using the quality attribute of the cfimage tag.

Image manipulation includes Rotate:

<cfset foo = imageRotate(myImage, 45)>

Resize:

<!--- 2nd attribute is width, 3rd attribute is height --->
<cfset foo = imageResize(myImage, "50%", "")>

Border:

<!--- 2nd atribute is thickness, 3rd is color,4th is border shape --->
<cfset foo = imageAddBorder(myImage, 5, "red", "constant">

Many more functions including imageShear, imageNegative, imageBrighten, imageBlur, etc.

Image resizing can be fixed width and height, proportional, and scale to fit.

Because there are so many functions, with lots of repeating attributes, you can use attribute collections and pass them to the image functions.

Base64 support allows you to embed images in HTML pages and emails. The new tags/functions allow you to do this a little easier than the current cffile/toBase64() method.

The cfimage tag will also support PNG captchas:

<cfimage action="captcha"
width="600"
height="150"
text="SAMPLE"
difficulty="low" <!--- low, medium, high" --->

destination="captcha.png">

Another cool feature is blob support. You'll be able to read and write blobs as well as convert images to blobs, making inserting and retrieving images from a database easy.

Exif and IPTC image metadata standards are supported for JPEG images. You can use the imageGetExifMetaData() and imageGetIPTCMetaData() functions respectively. There currently aren't any write functions, but that is subject to change before release.

There are quite a few drawing functions as well: geometric primitives, cubic and quadratic curves, and more. I think these are going to be interesting. One use case I have is diagraming workflow's. We have a workflow engine we use in several of our applications. It would be pretty cool to use the image drawing functions to actually diagram the workflow within a workflow administration application to make visualizing the workflow easier.

It looks to me like the cfimage tag and related functions in Scorpio are finally going to deliver a pretty powerful feature set that's been sorely lacking in ColdFusion for some time. Kudos to the development team on the implementation so far.

Given the information from the presentation, is there anything you feel the team may be missing?

Comments
Cutter's Gravatar Rob, only one question. What's the image quality like with image resizing? I know from live comparisons with the Alagad component, Rick Root's ImageCFC, and the ImageCR3 tag, that for quality you really have to stick to the .dll (ImageCR3). What's your take?
# Posted By Cutter | 10/25/06 10:13 PM
Erki Esken's Gravatar That's my question as well. If they take advantage of Photoshop resizing algorithms, then they have a winner. If it's just a wrapper for the Java imaging library functionality, then forget about it.
# Posted By Erki Esken | 10/26/06 4:54 AM
David Fekke's Gravatar Rob,

I wish I could have been there to see the presentation. Image support has been sorely laking from ColdFusion, and I am glad it is making it into 8.
# Posted By David Fekke | 10/26/06 2:23 PM
Rob Brooks-Bilson's Gravatar Hi Cutter,

The specifics of the underlying engine weren't discussed, but I believe that they are using the image capabilities in Java 1.5, which should be (from what I've read) a lot better than what's currently available in the CFMX 6/7 world. From the demos I saw, the resizing looked good, but without my own tests, I can't say for sure what the end result is going to be.
# Posted By Rob Brooks-Bilson | 10/30/06 9:52 AM
Netito's Gravatar I'm a bit late on this discussion, but EXIF and IPTC writing functionalities would be nice. I work on the online version of a newspaper thar receives lots of images from readers, and the capability of embed tags or geolocating the received images wolud be a real improvement for some applications....
# Posted By Netito | 1/31/07 10:05 AM
Peter Tilbrook's Gravatar Image quality was pretty dismal but has apparently been improved greatly. I've been too busy testing other new features to try this image stuff just yet.
# Posted By Peter Tilbrook | 4/13/07 6:34 PM
David Fried Oppenheim's Gravatar Just saw Ben Forta's presentation on Scorpio this past Monday and was more than a little impressed. According to Forta, the team at Adobe set about rewriting the image manipulation libraries as the ones that are part of Java currently suck. Yes, I agree... they suck. But with the Adobe image experts on board, I have high hopes that the quality of resizing and other image quality issues have been well handled. As a rule, I never get the new version as soon as it is released, but I honestly can't wait to get Scorpio.
# Posted By David Fried Oppenheim | 5/16/07 4:29 PM
Rob Brooks-Bilson's Gravatar It really does look like the Adobe influence is making it's way into CF. I think the cfimage tag, PDF support, and FDS are only the beginning.
# Posted By Rob Brooks-Bilson | 5/17/07 6:35 PM
sanyodenki's Gravatar I'm a bit late on this discussion, but EXIF and IPTC writing functionalities would be nice. I work on the online version of a newspaper thar receives lots of images from readers, and the capability of embed tags or geolocating the received images wolud be a real improvement for some applications
# Posted By sanyodenki | 8/22/07 3:31 AM



Copyright 1995-2008 Rob Brooks-Bilson. All rights reserved.
Aura skin for Raymond Camden's BlogCFC inspired by Joe Rinehart & Steven Erat. This blog is running version 5.5.1.