About ColdFusion images

ColdFusion lets you create and manipulate images dynamically. With ColdFusion, you can automate many image effects and drawing functions that you perform manually in Adobe Photoshop or other imaging software packages and integrate the images in your application. For example, contributors to a website can upload photos in different formats. You can add a few lines of code to your ColdFusion application to verify the images, reformat the images to a standard size and appearance, write the modified images to a database, and display the images in a browser.
The following table describes a few of the tasks you can perform with ColdFusion images:

Task

Functions and actions

Verify whether a ColdFusion variable returns an image

IsImage function

Verify whether a file is a valid image

IsImageFile function

Create thumbnail images

ImageScaleToFit function, the ImageResize function, or the resize action of the cfimage tag

Create a watermark

ImageSetDrawingTransparency function with any of the ImageDraw functions and the ImagePaste function

Get information about an image (for example, so you can enforce size restrictions)

ImageGetHeight and the ImageGetWidth functions or the ImageInfo function

Enforce compression on JPEG images

quality attribute of the write action of the cfimage tag or the ImageWrite function

Convert an image from one image file format to another (for example, convert a BMP file to a JPEG)

cfimage tag or ImageRead and ImageWrite functions

Convert an image file to a Base64 string

cfimage tag or the ImageWriteBase64 function

Create a ColdFusion image from a Base64 string

ImageReadBase64 function

Insert a ColdFusion image as a Binary Large Object Bitmap (BLOB) in a database

ImageGetBlob function within a cfquery statement

Create an image from a BLOB in a database

cfimage tag or the ImageNew function with a cfquery statement

Create an image from a binary object

cffile tag to convert an image file to a binary object and then pass the binary object to the ImageNew function

Create a Completely Automated Public Turing test to tell Computers and Humans Apart (CAPTCHA) image

captcha action of the cfimage tag

The ColdFusion image

A ColdFusion_ image_ is a construct that is native to ColdFusion. The ColdFusion image contains image data that it reads from a source. The source can be an image file or another ColdFusion image, which is expressed as a ColdFusion image variable. The ColdFusion image variable lets you manipulate information dynamically in memory. Optionally, you can write a ColdFusion image to a file, to a database column, or to a browser.

The cfimage tag

You use the cfimage tag to create a ColdFusion image and as a shortcut to commonly performed image functions, such as resizing an image, adding a border to an image, and converting an image to a different file format. You can use the cfimage tag independently or in conjunction with Image functions. You can pass a ColdFusion image created with the cfimage tag to one or more Image functions to perform complex image manipulation operations.
The following table summarizes the cfimage tag actions:

Action

Description

border

Creates a rectangular border around the outer edge of an image.

captcha

Creates a CAPTCHA image.

convert

Converts an image from one file format to another.

info

Creates a ColdFusion structure that contains information about the image, including the color model, height, width, and source of the image.

read

Reads an image from the specified local file path or URL. If you do not specify an action explicitly, ColdFusion uses read as the default value.

resize

Resizes the height and width of an image.

rotate

Rotates an image by degrees.

write

Writes the image to a file. You can use the write action to generate lower-resolution JPEG files. Also, use the write action to convert images to other file formats, such as PNG and GIF.

writeToBrowser

Writes one or more images directly to a browser. Use this action to test the appearance of a single image or write multiple images to the browser without saving the images to files.

For more information, see the cfimage tag in the CFML Reference.

Image functions

ColdFusion provides more than 50 Image functions that expand on the functionality of the cfimage tag. You can pass images created with the cfimage tag to Image functions or create images with the ImageNew function. The following table groups the Image functions by category:

Category

Image functions

Verifying images and supported image formats

IsImage, IsImageFile, GetReadableImageFormats, GetWriteableImageFormats

Retrieving image information

ImageGetEXIFTagImageGetEXIFMetadataImageGetIPTCMetadata, ImageGetHeight, ImageGetIPTCTag, ImageGetWidth, ImageInfo, ImageGetMetadata

Reading, writing, and converting images

ImageGetBlob, ImageGetBufferedImage, ImageNew, ImageRead, ImageReadBase64, ImageWrite, ImageWriteBase64

Manipulating images

ImageAddBorder, ImageBlur, ImageCopy, ImageCrop, ImageFlip, ImageGrayscale, ImageNegative, ImageOverlay, ImagePaste, ImageResize, ImageRotate, ImageScaleToFit, ImageSharpen, ImageShear, ImageTranslate

Drawing lines, shapes, and text

ImageDrawArc, ImageDrawBeveledRect, ImageDrawCubicCurve, ImageDrawLine, ImageDrawLines, ImageDrawOval, ImageDrawPoint, ImageDrawQuadraticCurve, ImageDrawRect, ImageDrawRoundRect, ImageDrawText

Setting drawing controls

ImageClearRect, ImageRotateDrawingAxis, ImageSetAntialiasing, ImageSetBackgroundColor, ImageSetDrawingColor, ImageSetDrawingStroke, ImageSetDrawingTransparency, ImageShearDrawingAxis, ImageTranslateDrawingAxis, ImageXORDrawingMode

 Adobe

Get help faster and easier

New user?