Creates a ColdFusion image.

imageNew([source] [, width] [, height] [, imagetype] [, canvascolor]) → returns any

Argument Reference

source string

The source image path, URL, a variable that is read into the new image, or a Java buffered image.

width numeric

The width of the new image. Valid when the height is specified and the source is not.

height numeric

The height of the new image. Valid when the width is specified and the source is not.

imagetype string

The type of the image to create (Valid only when width and height are specified),
  • rgb
  • argb
  • grayscale

canvascolor string
Default: black

Color of the image canvas. Possible values are:

Hexadecimal value of RGB color. For example, specify the color white as ##FFFFFF or FFFFFF.
String value of color (for example, 'black', 'red', 'green').
List of three numbers for (R,G,B) values. Each value must be in the range 0-255.

Sample code invoking the imageNew function

Use the imageNew function to create a 200x200-pixel image in ARGB format.

<cfset myImage = imageNew("",200,200,"argb")> 
<cfimage action="writeTobrowser" source="#myImage#">

This example shows how to create a ColdFusion image from a URL.

<cfset myImage = imageNew("")> 
<cfset imageWrite(myImage,"google_via_imagenew.png")> 
<img src="google_via_imagenew.png">

Signup for cfbreak to stay updated on the latest news from the ColdFusion / CFML community. One email, every friday.

Fork me on GitHub