So after my last post on embedding cfchart in email, I've been playing with cfchart and image functions. The ability to create an image out of cfchart isn't new, and we've got a butt load of new image functions in ColdFusion 8, so we should be able to mix the two up right? I whipped up a quick demo using imageUtils from RIAForge and a simple chart:
<cfset imageutils = createObject("component","imageutils.imageUtils")>
<cfchart format="png" name="mychart" chartheight="200" chartwidth="200" showlegend="false">
<cfchartseries type="pie">
<cfchartdata item="1Q Sales" value="500" />
<cfchartdata item="2Q Sales" value="400" />
<cfchartdata item="3Q Sales" value="700" />
<cfchartdata item="4Q Sales" value="200" />
</cfchartseries>
</cfchart>
<cfset mychart = imageNew(mychart)>
<cfset myfancychart = imageutils.reflectImage(mychart,"Bottom") />
<cfimage action="writetobrowser" source="#myfancychart#" />
Nothing too crazy here. I save the image binary into a variable and then 'load' it as an Image object using imageNew. I then use the reflectImage function to create...

I then got artsy:

So yeah, this was a complete waste of time. I can't think of anything I'd use CF8's image functions for that I can't do natively with cfchart itself, but maybe something intelligent will come to me later.
Archived Comments
I could see _maybe_ overlaying some text - like perhaps a watermark?
You can do text, a header, with cfchart, but a watermark would be useful perhaps.
I know this post isn't exclusively about cfimage, but I have to say that I think it the image functionality built into CF8 is one of the best features.
One area I've really been able to utilize cfimage is with dynamic image cropping and resizing. I have a web design gallery (css-imagine.com) that provides thumbnails and full-size images for featured site designs. Most people who have similar sites have to go through the work of taking screenshots, manually cropping and resizing, and finally uploading them to their website.
Not so with mine. CF8's image utils allow me to grab images taken with a free online screenshot service, re-size and crop them on the fly, and plop them into the right places in seconds. Where most of these similar sites have a lot of manual work to add a single entry, I literally only have to push a button (thanks to how easy cfc's make remote processing!), and it's done. CF8 seriously rocks, and I'm looking forward to see what 9 has to offer.
@existdissolve -- rather then rely on the external service you could take the screenshot yourself using CF 8 if you wanted to.
Ray blogged about it: http://www.coldfusionjedi.c...
@todd -
I tried that method, but was not happy with the results it produced. It's pretty good for thumbnails (e.g., something < 200px), but for the full-scale images the result was too inconsistent to be a feasible option. Thanks for the link, though!
@Existdissolve - when ya gonna reskin my blog and make it sexier? ;)
"expirement"? hehe sorry..had to point that out :)
Fixed. Spelling is for nerds! ;)
Heck yeah, I can see lots of uses. Custom legends, headers and a fancy data table even though you can get that with a style. Great idea, keep the juices flowing.
" I can't think of anything I'd use CF8's image functions for that I can't do natively with cfchart itself, but maybe something intelligent will come to me later."
Hi Ray, I have just finished adding Bullet Graphs to my SparklineCFC project. That's somethign you cant do with CFChart.
Have a look.
http://www.dashcapper.com/2...
That is dang sweet Fred, thanks for sharing it.
@ray--
March-ish? Seriously, I'll do it (I owe you for all the code, advice and interesting stuff you post all the time) :)
Just ping me and we will talk. Thanks. :)
This experience may have been useless, but the use of tag <cfimage action="writetobrowser"> to display <cfchart> graph saved me from the annoying message "Expired Image. Please refresh the page to view the image." Thank you Raymond.
You are most welcome. :)