Creates a ColdFusion image that can be manipulated by using image functions.
You can use the cfimage tag to perform common image manipulation operations as a shortcut to Image functions.
You can use the cfimage tag independently or in conjunction with image functions.



Attribute Reference for the cfimage tag


Required: No
Default: read
The action to take. Must be one of the following:
You do not need to specify the default action, read, explicitly. Values:
  • border
  • captcha
  • convert
  • info
  • read
  • resize
  • rotate
  • write
  • writeToBrowser


Required: No
Angle in degrees to rotate the image.


Required: No
(border) Border color.
Hexadecimal value or supported named color.
For a hexadecimal value, use the form "##xxxxxx" or "xxxxxx". (required)


Required: No
Absolute or relative pathname where the image output is written.
The image format is determined by the file extension.
The convert and write actions require a destination.
The border, captcha, resize, and rotate actions require either a name attribute or a destination attribute.
You can specify both.
Scorpio supports only CAPTCHA images in PNG format.
If you do not enter a destination, the CAPTCHA image is placed inline in the HTML output and displayed in the web browser.


Required: No
Default: low
Level of complexity of the CAPTCHA text.
Specify one of the following levels of text distortion:
low Values:
  • high
  • medium
  • low


Required: No
Font size of the text in the CAPTCHA image.
The value must be an integer.


Required: No
Format of the image displayed in the browser.
If you do not specify a format, the image is displayed in PNG format.
You cannot display a GIF image in a browser.
GIF images are displayed in PNG format. Values:
  • png
  • jpg
  • jpeg


Required: No
Height in pixels of the image.
For the resize attribute, you also can specify the height as a percentage (an integer followed by the "%" symbol).
The value must be an integer.


Required: No
Default: false
Specifies whether the source is a Base64 string.
The isBase64 values are:
yes: the source is a Base64 string.
no: the source is not a Base64 string.


Required: No
Name of the ColdFusion image variable to create.
The read action requires name attribute.
The border, resize, and rotate options require a name attribute or a destination attribute.
You can specify both.


Required: No
Default: false
Valid only if the destination attribute is specified. The overwrite values are:
yes: overwrites the destination file.
no: does not overwrite the destination file.
If the destination file already exists, ColdFusion generates an error if the overwrite option is not set to yes.


Required: No
Default: 0.75
Quality of the JPEG destination file.
Applies only to files with an extension of JPG or JPEG.
Valid values are fractions that range from 0 through 1
(the lower the number, the lower the quality).


Required: No
URL of the source image; for example, " images/logo.gif"
Absolute or relative pathname of the source image; for example, "c:\wwwroot\images\logo.jpg"
ColdFusion image variable containing another image, BLOB, or byte array; for example, "#myImage#"
Base64 string; for example, "data:image/jpg;base64,/9j/ 4AAQSkZJRgABAQA.............."


Required: No
Name of the ColdFusion structure to be created.


Required: No
Text string displayed in the CAPTCHA image.
Use capital letters for better readability.


Required: No
Default: 1
Border thickness in pixels.
The border is added to the outside edge of the source image,
increasing the image area accordingly.
The value must be an integer.


Required: No
Width in pixels of the image.
For resize, you also can specify the width as a percentage
(an integer followed by the "%" symbol).
The value must be an integer.


Required: No
One or more valid fonts to use for the CAPTCHA text. Separate multiple fonts with commas. ColdFusion supports only the system fonts that the JDK can recognize.


Required: No
Default: highestQuality
CF 10+ Used when action=resize determines the interpolation algorithm to use. Values:
  • highestQuality
  • highQuality
  • mediumQuality
  • highestPerformance
  • highPerformance
  • mediumPerformance
  • nearest
  • bilinear
  • bicubic
  • bessel
  • blackman
  • hamming
  • hanning
  • hermite
  • lanczos
  • mitchell
  • quadratic

Links more information about cfimage

Examples sample code using the cfimage tag

Border action

Add a red border of 5 pixels to an image, write the output to a variable.

<cfimage action="border" source="#sourceImage#" size=5 color="red" name="withborder">

Captcha action

Generate a CAPTCHA style image using medium difficulty.

<cfimage action="captcha" text="Captcha!" difficulty="medium" fontSize="18" fonts="Comic Sans MS,Times New Roman">

Convert action

Convert an image to a different format (in this case PNG).

<cfimage action="convert" source="#sourceImage#" destination="#expandPath( 'destination.png' )#" overwrite="true">

Info action

Retrieve meta data from an image and stores that as a structure in a variable.

<cfimage action="info" source="" structname="imageInfo">
<cfdump var="#imageInfo#">

Read action

Tag syntax for reading an image from a URL.

<cfimage action="read" name="sourceImage" source="">

Resize action

Example of resizing an image stored in a variable and storing the result in a variable.

<cfimage action="resize" source="#sourceImage#" height="200" width="200" name="resized">

Rotate action

Rotate an image 30 degrees clockwise.

<cfimage action="rotate" source="#sourceImage#" destination="#expandPath( 'rotated.jpg' )#" overwrite="true" angle="30" quality="1">

Write action

Example of writing an image as an 80% compressed jpg image.

<cfimage action="write" source="#sourceImage#" destination="#expandPath( 'newImage.jpg' )#" overwrite="true" quality=".2">

WriteToBrowser action

Generates HTML to output the image in place.

<cfimage action="writeToBrowser" source="#sourceImage#">

Fork me on GitHub