Writes Base64 images to the specified filename and destination.
Base64 string.
ImageWriteBase64(name
,destination
,format
[,inHTMLFormat
])
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 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,...") :
|
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.
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:
<!--- 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")>