ColdFusion 9.0 Resources |
ImageWriteBase64Parameters
UsageYou use the ImageWriteBase64 function to encode image data as a string of printable characters. This is useful for several applications, including sending images by e-mail and storing images in database text fields. Use the following syntax to specify an in-memory file, which is not written to disk. In-memory files speed processing of transient data. ram:///filepath The filepath can include directories, for example ram:///petStore/images/poodle.jpg. Create the directories in the path before you specify the file. For more information on using in-memory files, see Optimizing transient files in the Developing ColdFusion Applications. If you do not specify a file format, ColdFusion cannot recognize the format required to encode the image before converting to Base64, and generates errors. You can verify whether ColdFusion reads a Base64 string properly in the following ways:
Example<!--- This example shows how to convert a JPEG image to Base64 format and save it to a file. ---> <!--- Create a new ColdFusion image. ---> <cfset myImage=ImageNew("../cfdocs/images/artgallery/jeff01.jpg")> <!--- Convert the image to Base64 format and write it to a file.---> <cfset ImageWriteBase64(myImage,"jeffBase64.txt","jpg","yes")> |