ImageCFC: Documentation: Method Description

imageCFC.writeImage()

Description

Writes a java BufferedImage object to the file system.

Returns

A structure containing the following fields:

keyvalue
errorCode0 for success, non-zero for failure. Always returned, but not really used if the throwOnError option is set to true.
errorMessageA description of the error. Always returned, but not really used if the throwOnError option is set to true.

Function Syntax

writeImage(outputFile, objImage, jpegCompression)

ParameterRequired?DefaultDescription
outputFile YES - File path to write the output.
objImage YES - A java image object.
jpegCompression NO defaultJpegCompression jpeg compression quality to use if writing a jpeg file. 0-100. 100 is the highest quality.

Example

The following example reads an image from a url and saves it locally to disk using the readImage() and writeImage() methods.

<cfset imageCFC = createObject("component","image")>
<cfset img = imageCFC.readImage("http://www.somedomain.com/myimage.jpg")>
<cfset results = imageCFC.writeImage(img, "C:\Inetpub\wwwroot\myimage.jpg")>