imageNew

Creates a ColdFusion image.

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

imageNew Argument Reference

source

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

width

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

height

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

imagetype

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

canvascolor
Default: black

Color of the image canvas Values:
  • 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


Tag Syntax

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

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

Tag Syntax

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