[Coldbox 3.8.1] User uploaded image - convert all white pixels to tranparent

Does anyone have advice on how I can convert all white pixels in a user uploaded image to transparent? These images will be mainly signatures.

Any help is appreciated.
Thank you.
-Chris Keeler

Thanks to a little help from Ben Nadel’s blog post, I came up with this:


<cfset arraySet(local.averagePixelBuffer,1,(local.pixelWidth * local.pixelHeight),local.pixelAverage) />
<cfset local.newbufferedImage.setRGB(
javaCast( “int”, local.x ),
javaCast( “int”, local.y ),
javaCast( “int”, local.pixelWidth ),
javaCast( “int”, local.pixelHeight ),
javaCast( “int[]”, local.averagePixelBuffer ),
javaCast( “int”, 0 ),
javaCast( “int”, local.pixelWidth )
) />



Hope it will help someone else.