converts an image from one supported format to another.
A structure containing the following fields:
| key | value |
|---|---|
| errorCode | 0 for success, non-zero for failure. Always returned, but not really used if the throwOnError option is set to true. |
| errorMessage | A description of the error. Always returned, but not really used if the throwOnError option is set to true. |
| img | A java BufferedImage object is returned if no output file is specified |
convert(objImage,inputFile,outputFile,jpegCompression)
| Parameter | Required? | Default | Description |
|---|---|---|---|
| objImage | YES | - | A java image object, or a blank string. |
| inputFile | YES | - | File path or URL to an image, or a blank string. |
| outputFile | YES | - | File path to write the output, or a blank string. |
| jpegCompression | NO | defaultJpegCompression | jpeg compression quality to use if writing a jpeg file. 0-100. 100 is the highest quality. |
You must supply either an image object or a file path to a source image.
NOTE: Java image conversion bases the output type on the file extension. This method will throw an error if you specify a file extension that java cannot figure out how to deal with.
<cfset imageCFC = createObject("component","image")>
<cfset imgInfo = imageCFC.convert("", "C:\Inetpub\wwwroot\myimage.jpg", "C:\Inetpub\wwwroot\myimage.png")>
<img src="myimage.png" alt="image converted to PNG"/>