> Base64 to image file in CF7???
I would guess one of the open source CFC's like
ImageCFC already
does this. However, you can convert the bas64 string to an image
file using a little java. I believe the image formats you can
read/write are determined by the JVM. More specifically, by the
readers/writers registered with the jvm. I think MX7 installs jvm
1.4.2 by default, which is capable of
reading gif images, but not writing them to disk. The CF8's
JVM (1.6), on the other hand, is capable of writing gif's to disk.
This code will display the mime types supported for read and
write operations. Plus the informal names you can use when writing
out an image. An informal names is similar to a file extension like
"jpeg" or "png".
<cfset ImageIO = createObject("java",
"javax.imageio.ImageIO")>
<cfset readerNames = ImageIO.getReaderFormatNames()>
<cfset readerMimeTypes = ImageIO.getReaderMimeTypes()>
<cfset writerNames = ImageIO.getWriterFormatNames()>
<cfset writerMimeTypes = ImageIO.getWriterMIMETypes()>
<cfdump var="#writerMimeTypes#"
label="writerMimeTypes">
<cfdump var="#readerMimeTypes#"
label="readerMimeTypes">
<cfdump var="#readerNames#" label="readerNames">
<cfdump var="#writerNames#" label="writerNames">
Here is an example of how you could decode and save a jpeg
image to disk.
<cfscript>
// convert the base 64 string to binary
binaryData = binaryDecode(base64Image, "base64");
inStream = createObject("java",
"java.io.ByteArrayInputStream").init( binaryData );
ImageIO = createObject("java", "javax.imageio.ImageIO");
// convert the bytes to a BufferedImage
buffImage = ImageIO.read( inStream );
// indicate where to save the image file
outputPath = ExpandPath("savedFile.jpg");
saveToFile = createObject("java", "java.io.File").init(
outputPath );
// write the file to disk
wasWritten = ImageIO.write( buffImage, "jpeg", saveToFile);
WriteOutput("was written to disk="& wasWritten);
</cfscript>