Transparent Backgrounds for CF8 CFImage

Can you create an image with a transparent background, but it takes creating some Java objects. I'll be posting the code as part of an image effects set, but you an follow the steps here to figure out how to do it.

 

Problems with Image Copying in CF8

I ran into an interesting problem with ColdFusion 8's image functions. I wanted to compare my image from before I added my effect, and my image after. Simple right? Well no, no its not. I'm doing my image manipulations in function, so I wanted to pass in the original image, and save the result to a new variable, but I kept coming out with two copies of the same image. It took me a bit, but I finally found a solution.

 

Foundeo's Rounded Borders

I know I said that I wouldn't do it, but I've become obsessed with figuring out replicate the rounded borders effect for CF8 that Foundeo included in its Effects CFC. I tried drawing rounded rectangles with large brush strokes to do it, but I keep messing up the diameters... maybe I'm just not getting it right.

Any one have any ideas?

 

Implementing Sleep in CF

So I'm trying to import around 10,000 records through loops in CF7, because I have to tack in some additional info for each record... fun. I'd like to sleep the process for a bit, but CF7 doesn't have a built in method for that... Java objects to the rescue.

Java Object Sleep in CF7


<cfset objThread = CreateObject("java", "java.lang.Thread")>
<cfset objThisThread = objThread.currentThread()>
<cfset objThisThread.sleep(500)>

But, as someone at House of Fusion warns:

[The] thread [is] in the queue sleeping, and so if you have configged CF to use max 20 CF threads, and you sleep 20 threads, no requests will be handled by the server unless one of the threads gets free.

Below you can find the syntax for doing this in CF8, as mentioned by Jeff. Thanks for pointing that out Jeff!


<!--- Sleep current thread for 5 seconds --->
<cfset sleep(5000)/>

 

CFImage Effects

I know that Foundeo has created an Image Effects CFC that can do image gradients and the "iTunes" mirroring effect, but while I was sitting at home today with a bit of a cold, I just had to make this effect myself. Unfortunately, I figured out in the process that I needed a gradient effect while I was creating this function, so they are both here. All in all, not too hard. I realized that the iTunesMirror function should be tacking on a boarder to the non-reflection, but I think it works well enough as is.

 

StackCore

I've come up with a .02 version of warpcore using a Java Stack as the event manager, but from simple testing it doesn't seem to be as fast as the previous version. I'm going to have to narrow this down to creation time or execution time though.

Click more to see the code.

 
Jon Hartmann, July 2011

I'm Jon Hartmann and I'm a Javascript fanatic, UX/UI evangelist and former ColdFusion master. I blog about mysterious error messages, user interface design questions, and all things baffling and irksome about programming for the web.

Learn more about me on LinkedIn.