Wednesday 26 Nov 2014   
Add Comment

Transparent Images with ColdFusion 10 Tutorial

ColdFusion Tutorial #21

ColdFusion 8's new Image manipulation functionality is pretty awesome, I think we can all agree on that. The documentation on how to use it is also very clear on all aspects except on the topic of creating transparent images. The live docs are not only unclear as to how one can do this but also whether or not this is even be done with CF8.


Look at one of the Notes that is part of the documentation:

Note: If you specify the ARGB image type, the image is white; however, if you specify RGB or grayscale, the image is black. To create blank images consistently, use the canvasColor parameter.

This statement isn't necessarily unclear; I think it's just downright misleading. At first glance, it looks like the canvas type, ARGB or RGB, simply changes the background color from white to black. Then, it says to create a "blank" canvas consistently, use the cavasColor parameter. What does "blank" mean? Transparent? Empty? If the first sentence talked about color, then it might lead that the second sentence talks about transparency?This is all very poorly worded and doesn't mention "transparent" properties at all.

You might think that maybe it has to do with the default drawing color, but it does not. Whether you create a canvas of type RGB or ARGB, the default drawing color is still white.

Despite the confusing live docs, rest assured that creating a transparent canvas (transparent image) in ColdFusion 8 is not only possible, it is, in fact, quite simple. The trick is to use the canvas type ARGB and to not specify a canvas color at all. The "A" in "argb" stands for "alpha" and provides the canvas with an alpha channel (for transparency). Then, by not specifying the canvas color, which is an optional argument, we make sure not to cover the transparent background with a color fill.


See this code running!


Download this code as a zip!


There are no comments!

Click button to add a comment


Ben Nadel


Tuesday 27 Nov 2007


This tutorial has been modified and published with permission of the author. The original tutorial can be found here 


cfimage  cfset