Description
Writes Base64 images to the specified on-disk or in-memory destination.
Returns
Base64 string.
Writes Base64 images to the specified on-disk or in-memory destination.
Base64 string.
1 | ImageWriteBase64 (name, destination, format [, inHTMLFormat, optional]) |
cfimage, ImageReadBase64, IsImageFile
ColdFusion 8: Added this function.
Parameter |
Description |
---|---|
name |
Required. The ColdFusion image on which this operation is performed. |
destination |
Required. The absolute or relative on-disk or in-memory pathname where you write the file. |
format |
Required. The format |
inHTMLFormat |
Optional. Specify whether Base64 output includes the headers used by the Base64 images in the HTML <img> tag ("data:image/<format>;base64,...") :
|
overwrite |
Optional. If set to true, overwrites the destination file. |
You 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 Working with in-memory files in Optimizing ColdFusion applications 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:
1 2 3 4 | <!--- 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" )> |