imageNew

Creates a ColdFusion image.

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

imageNew 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),
Values:
  • 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.

Examples 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("http://www.google.com/images/logo_sm.gif")> 
<cfset imageWrite(myImage,"google_via_imagenew.png")> 
<img src="google_via_imagenew.png">

Fork me on GitHub