Utility Function: ImageBlurMore()

OK, so up until now you probably can guess that the functionality I'm working on has something to do with drawing or moving a shape since I've posted math rounding functions and functions dealing with geometric positioning. Lets throw you a curve-ball: I also need the following function. What happens when ImageBlur(image, 10) just isn't enough? Well you're going to need to blur the image more!

<cffunction name="ImageBlurMore" output="false" returntype="void">
    <cfargument name="Image" type="any" required="true" />
    <cfargument name="Blur" type="numeric" required="false" default="11" />
    <cfset var local = StructNew() />
    <!--- Set blur tracker --->
    <cfset local.blur = arguments.Blur />
    <!--- Loop until all of the blur has been assigned --->
    <cfloop condition="local.blur gt 0">
        <!--- If the blur value is too small, end the function --->
        <cfif local.blur lt 3>
            <cfbreak />
        <!--- If the blur is large enough, use the maximum blur --->
        <cfelseif local.blur gte 13>
            <cfset local.blurStep = 10 />
        <!--- If the blur is within normal ImageBlur(), us it --->
        <cfelseif local.blur lte 10>
            <cfset local.blurStep = local.blur />
        <!--- Otherwise, set the blur such that a valid blur amount isleft --->
            <cfset local.blurStep = local.blur - 3 />
        <!--- Apply the blur --->
        <cfset ImageBlur(arguments.Image, local.blurStep) />
        <!--- Update the blur tracker --->
        <cfset local.blur = local.blur - local.blurStep />
    <cfreturn />

This function handles breaking up a blur value of more than a single increment of 10, so that you don't need to call blur multiple times yourself.

Please note that I make no claim that ImageBlurMore(image, 20) is really equivalent to the image being blurred with a radius of 20. All I can do from ColdFusion is apply ImageBlure(image, 10) twice and hope its close. If you need something more accurate, look at the Java API and let me know what you find!



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.

Post a job. Find one. authenticjobs.com

Interested in becoming a sponsor? Contact me.