I had problems with toBase64 () for a while. I hope someone tells me why CF toBase64 () seems to be missing something, i.e. in my example, this reduces image quality.
I have a solution (see the last code example below), but I hate not understanding why and would like to solve it, this is CF.
If someone is so kind as to run the code below, you will see that after toBase64 conversion, the image quality is poor. Nothing serious, but after encoding it doesnโt look so good. If you have never noticed this, try, you will understand what I mean.
Does anyone know why, or how to solve this in CF?
<cfset image = ImageNew("test.png")> <cfimage action="writeToBrowser" source="#image#" > <cfset image = toBinary(toBase64(image)) /> <cfimage action="writeToBrowser" source="#image#" >
<cfset image = ImageNew("test.png")> <cfset FileWrite(expandPath('./converted.image'),toBinary(toBase64(image))) />
My solution was to use the java add-in, and everything seemed fine, but for reasons that I will not go into, I canโt live live.
image = createObject("java","it.sauronsoftware.base64.Base64").encode(image); toBinary(image );
An example of outputting the image with the code above can be found here: http://i56.tinypic.com/29fwiq.png First, before toBase64 appears after the second, you can see that the image has lost some quality after the toBase64 function on the second output.
Update: As Peter noted, the problem is with the automatic output / conversion code in ImageObject to provide binary output for the toBase64 function for encoding.
Update I presented this as an error in CF 9.0.1, vote for error 3177303 https://bugbase.adobe.com/index.cfm?event=bug&id=3177303