- CFML Reference User Guide
- ColdFusion functions
- ColdFusion functions by category
- Functions a-b
- Abs
- ACos
- AddSOAPRequestHeader
- AddSOAPResponseHeader
- AjaxLink
- AjaxOnLoad
- ApplicationStop
- ArrayAppend
- ArrayAvg
- ArrayClear
- ArrayContains
- ArrayContainsNoCase
- ArrayDelete
- ArrayDeleteAt
- ArrayDeleteNoCase
- ArrayEach
- ArrayFilter
- ArrayFind
- ArrayFindAll
- ArrayFindAllNoCase
- ArrayFindNoCase
- ArrayInsertAt
- ArrayIsDefined
- ArrayIsEmpty
- ArrayLen
- ArrayMap
- ArrayMax
- ArrayMin
- ArrayNew
- ArrayPrepend
- ArrayReduce
- ArrayResize
- ArraySet
- ArraySetMetadata
- ArraySlice
- ArraySort
- ArraySum
- ArraySwap
- ArrayToList
- Asc
- ASin
- Atn
- AuthenticatedContext
- AuthenticatedUser
- BinaryDecode
- BinaryEncode
- BitAnd
- BitMaskClear
- BitMaskRead
- BitMaskSet
- BitNot
- BitOr
- BitSHLN
- BitSHRN
- BitXor
- BooleanFormat
- Abs
- Functions-c-d
- CacheGet
- CacheGetAllIds
- CacheGetMetadata
- CacheGetProperties
- CacheGetSession
- CacheIdExists
- CachePut
- CacheRegionExists
- CacheRegionNew
- CacheRegionRemove
- CacheRemove
- CacheRemoveAll
- CacheSetProperties
- CallStackDump
- CallStackGet
- CanDeSerialize
- Canonicalize
- CanSerialize
- Ceiling
- CharsetDecode
- CharsetEncode
- Chr
- CJustify
- Compare
- CompareNoCase
- Cos
- CreateDate
- CreateDateTime
- CreateObject
- CreateObject: .NET object
- CreateObject: COM object
- CreateObject: component object
- CreateObject: CORBA object
- CreateObject: Java or EJB object
- CreateObject: web service object
- CreateODBCDate
- CreateODBCDateTime
- CreateODBCTime
- CreateSignedJWT
- CreateEncryptedJWT
- CreateTime
- CreateTimeSpan
- CreateUUID
- CSRFGenerateToken
- CSRFVerifyToken
- DateAdd
- DateCompare
- DateConvert
- DateDiff
- DateFormat
- DatePart
- DateTimeFormat
- Day
- DayOfWeek
- DayOfWeekAsString
- DayOfYear
- DaysInMonth
- DaysInYear
- DE
- DecimalFormat
- DecodeForHTML
- DecodeFromURL
- DecrementValue
- Decrypt
- DecryptBinary
- DeleteClientVariable
- Deserialize
- DeserializeJSON
- DeserializeXML
- DirectoryCopy
- DirectoryCreate
- DirectoryDelete
- DirectoryExists
- DirectoryList
- DirectoryRename
- DollarFormat
- DotNetToCFType
- Duplicate
- Functions-e-g
- EncodeForCSS
- EncodeForDN
- EncodeForHTML
- EncodeForHTMLAttribute
- EncodeForJavaScript
- EncodeForLDAP
- EncodeForURL
- EncodeForXML
- EncodeForXMLAttribute
- EncodeForXpath
- Encrypt
- EncryptBinary
- EntityDelete
- EntityLoad
- EntityLoadByExample
- EntityLoadByPK
- EntityMerge
- EntityNew
- EntityReload
- EntitySave
- EntityToQuery
- Evaluate
- Exp
- ExpandPath
- FileClose
- FileCopy
- FileDelete
- FileExists
- FileGetMimeType
- FileIsEOF
- FileMove
- FileOpen
- FileRead
- FileReadBinary
- FileReadLine
- FileSeek
- FileSetAccessMode
- FileSetAttribute
- FileSetLastModified
- FileSkipBytes
- FileUpload
- FileUploadAll
- FileWrite
- FileWriteLine
- Find
- FindNoCase
- FindOneOf
- FirstDayOfMonth
- Fix
- Floor
- FormatBaseN
- GeneratePBKDFKey
- GenerateSecretKey
- GetApplicationMetadata
- GetAuthUser
- GetBaseTagData
- GetBaseTagList
- GetBaseTemplatePath
- GetClientVariablesList
- GetComponentMetaData
- GetContextRoot
- GetCPUUsage
- GetCurrentTemplatePath
- GetDirectoryFromPath
- GetEncoding
- GetException
- GetFileFromPath
- GetFileInfo
- GetFreeSpace
- GetFunctionCalledName
- GetFunctionList
- GetGatewayHelper
- GetHttpRequestData
- GetHttpTimeString
- GetK2ServerDocCount
- GetK2ServerDocCountLimit
- GetLocale
- GetLocaleDisplayName
- GetLocalHostIP
- GetMetaData
- GetMetricData
- GetPageContext
- GetPrinterInfo
- GetPrinterList
- GetProfileSections
- GetProfileString
- GetReadableImageFormats
- GetSafeHTML
- GetSAMLAuthRequest
- GetSAMLLogoutRequest
- GenerateSAMLSPMetadata
- GetSOAPRequest
- GetSOAPRequestHeader
- GetSOAPResponse
- GetSOAPResponseHeader
- GetSystemFreeMemory
- GetSystemTotalMemory
- GetTempDirectory
- GetTempFile
- GetTemplatePath
- GetTickCount
- GetTimeZoneInfo
- GetToken
- GetTotalSpace
- GetUserRoles
- GetVFSMetaData
- GetWriteableImageFormats
- Functions-h-im
- Hash
- HMac
- Hour
- HQLMethods
- HTMLCodeFormat
- HTMLEditFormat
- IIf
- ImageAddBorder
- ImageBlur
- ImageClearRect
- ImageCopy
- ImageCreateCaptcha
- ImageCrop
- ImageDrawArc
- ImageDrawBeveledRect
- ImageDrawCubicCurve
- ImageDrawLine
- ImageDrawLines
- ImageDrawOval
- ImageDrawPoint
- ImageDrawQuadraticCurve
- ImageDrawRect
- ImageDrawRoundRect
- ImageDrawText
- ImageFlip
- ImageGetBlob
- ImageGetBufferedImage
- ImageGetEXIFMetadata
- ImageGetEXIFTag
- ImageGetHeight
- ImageGetIPTCMetadata
- ImageGetIPTCTag
- ImageGetMetadata
- ImageGetWidth
- ImageGrayscale
- ImageInfo
- ImageMakeColorTransparent
- ImageMakeTranslucent
- ImageNegative
- ImageNew
- ImageOverlay
- ImagePaste
- ImageRead
- ImageReadBase64
- ImageResize
- ImageRotate
- ImageRotateDrawingAxis
- ImageScaleToFit
- ImageSetAntialiasing
- ImageSetBackgroundColor
- ImageSetDrawingColor
- ImageSetDrawingStroke
- ImageSetDrawingTransparency
- ImageSharpen
- ImageShear
- ImageShearDrawingAxis
- ImageTranslate
- ImageTranslateDrawingAxis
- ImageWrite
- ImageWriteBase64
- ImageXORDrawingMode
- Functions-in-k
- IncrementValue
- InputBaseN
- Insert
- Int
- InvalidateOauthAccesstoken
- Invoke
- InitSAMLAuthRequest
- InitSAMLLogoutRequest
- InvokeCFClientFunction
- IsArray
- IsAuthenticated
- IsAuthorized
- IsBinary
- IsBoolean
- IsClosure
- IsCustomFunction
- IsDate
- IsDateObject
- IsDDX
- IsDebugMode
- IsDefined
- IsImage
- IsImageFile
- IsInstanceOf
- IsIPv6
- IsJSON
- IsK2ServerABroker
- IsK2ServerDocCountExceeded
- IsK2ServerOnline
- IsLeapYear
- IsLocalHost
- IsNull
- IsNumeric
- IsNumericDate
- IsObject
- isOnline
- IsPDFArchive
- IsPDFFile
- IsPDFObject
- IsProtected
- IsQuery
- isSamlLogoutResponse
- isSafeHTML
- IsSimpleValue
- IsSOAPRequest
- IsSpreadsheetFile
- IsSpreadsheetObject
- IsStruct
- IsUserInAnyRole
- IsUserInRole
- IsUserLoggedIn
- IsValid
- IsValidOauthAccesstoken
- IsWDDX
- IsXML
- IsXmlAttribute
- IsXmlDoc
- IsXmlElem
- IsXmlNode
- IsXmlRoot
- JavaCast
- JSStringFormat
- Functions-l
- LCase
- Left
- Len
- ListAppend
- ListChangeDelims
- ListContains
- ListContainsNoCase
- ListDeleteAt
- ListEach
- ListFilter
- ListFind
- ListFindNoCase
- ListFirst
- ListGetAt
- ListInsertAt
- ListLast
- ListLen
- ListMap
- ListPrepend
- ListQualify
- ListReduce
- ListRemoveDuplicates
- ListRest
- ListSetAt
- ListSort
- ListToArray
- ListValueCount
- ListValueCountNoCase
- LJustify
- Location
- Log
- Log10
- LSCurrencyFormat
- LSDateFormat
- LSDateTimeFormat
- LSEuroCurrencyFormat
- LSIsCurrency
- LSIsDate
- LSIsNumeric
- LSNumberFormat
- LSParseCurrency
- LSParseDateTime
- LSParseEuroCurrency
- LSParseNumber
- LSTimeFormat
- LTrim
- Functions-m-r
- Max
- Mid
- Min
- Minute
- Month
- MonthAsString
- Now
- NumberFormat
- ObjectEquals
- ObjectLoad
- ObjectSave
- OnWSAuthenticate
- ORMClearSession
- ORMCloseAllSessions
- ORMCloseSession
- ORMEvictCollection
- ORMEvictEntity
- ORMEvictQueries
- ORMExecuteQuery
- ORMFlush
- ORMFlushall
- ORMGetSession
- ORMGetSessionFactory
- ORMIndex
- ORMIndexPurge
- ORMReload
- ORMSearch
- ORMSearchOffline
- ParagraphFormat
- ParameterExists
- ParseDateTime
- Pi
- PrecisionEvaluate
- ProcessSAMLResponse
- ProcessSAMLLogoutRequest
- Quarter
- PreserveSingleQuotes
- QueryAddColumn
- QueryAddRow
- QueryConvertForGrid
- QueryExecute
- QueryFilter
- QueryGetResult
- QueryGetRow
- QueryKeyExists
- QueryMap
- QueryNew
- QueryReduce
- QuerySetCell
- QuotedValueList
- QueryEach
- Rand
- Randomize
- RandRange
- ReEscape
- REFind
- REFindNoCase
- ReleaseComObject
- REMatch
- REMatchNoCase
- RemoveCachedQuery
- RemoveChars
- RepeatString
- Replace
- ReplaceList
- ReplaceNoCase
- REReplace
- REReplaceNoCase
- RestDeleteApplication
- RestSetResponse
- RestInitApplication
- Reverse
- Right
- RJustify
- Round
- RTrim
- Functions-s
- Second
- SendGatewayMessage
- SendSAMLLogoutResponse
- Serialize
- SerializeJSON
- SerializeXML
- SessionInvalidate
- SessionRotate
- SessionGetMetaData
- SessionInvalidate
- SessionRotate
- SetDay
- SetEncoding
- SetHour
- SetLocale
- SetMonth
- SetProfileString
- SetVariable
- SetYear
- Sgn
- Sin
- Sleep
- SpanExcluding
- SpanIncluding
- SpreadsheetAddAutoFilter
- SpreadsheetAddColumn
- SpreadsheetAddFreezePane
- SpreadsheetAddImage
- SpreadsheetAddInfo
- SpreadsheetAddPageBreaks
- SpreadsheetAddRow
- SpreadsheetAddRows
- SpreadsheetAddSplitPane
- SpreadsheetCreateSheet
- SpreadsheetDeleteColumn
- SpreadsheetDeleteColumns
- SpreadsheetDeleteRow
- SpreadsheetDeleteRows
- SpreadsheetFormatCell
- SpreadsheetFormatColumn
- SpreadsheetFormatCellRange
- SpreadsheetFormatColumn
- SpreadsheetFormatColumns
- SpreadsheetFormatRow
- SpreadsheetFormatRows
- SpreadsheetGetCellComment
- SpreadsheetGetCellFormula
- SpreadsheetGetCellValue
- SpreadsheetGetColumnCount
- SpreadsheetInfo
- SpreadsheetMergeCells
- SpreadsheetNew
- SpreadsheetRead
- SpreadsheetReadBinary
- SpreadsheetRemoveSheet
- SpreadsheetSetActiveSheet
- SpreadsheetSetActiveSheetNumber
- SpreadsheetSetCellComment
- SpreadsheetSetCellFormula
- SpreadsheetSetCellValue
- SpreadsheetSetColumnWidth
- SpreadsheetSetFooter
- SpreadsheetSetHeader
- SpreadsheetSetRowHeight
- SpreadsheetShiftColumns
- SpreadsheetShiftRows
- SpreadsheetWrite
- Sqr
- StripCR
- StructAppend
- StructClear
- StructCopy
- StructCount
- StructDelete
- StructEach
- StructFilter
- StructFind
- StructFindKey
- StructFindValue
- StructGet
- StructGetMetadata
- StructInsert
- StructIsEmpty
- StructKeyArray
- StructKeyExists
- StructKeyList
- StructMap
- StructNew
- StructReduce
- StructSetMetadata
- StructSort
- StructToSorted
- StructUpdate
- StoreSetMetadata
- StoreGetACL
- StoreGetMetadata
- StoreAddACL
- StoreSetACL
- Functions-t-z
- Tan
- ThreadJoin
- ThreadTerminate
- Throw
- TimeFormat
- ToBase64
- ToBinary
- ToScript
- ToString
- Trace
- Transactionandconcurrency
- TransactionCommit
- TransactionRollback
- TransactionSetSavePoint
- Trim
- UCase
- URLDecode
- URLEncodedFormat
- URLSessionFormat
- Val
- ValueList
- VerifyClient
- Week
- Wrap
- WriteDump
- WriteLog
- WriteOutput
- WSGetAllChannels
- WSGetSubscribers
- WSPublish
- WSSendMessage
- XmlChildPos
- XmlElemNew
- XmlFormat
- XmlGetNodeType
- XmlNew
- XmlParse
- XmlSearch
- XmlTransform
- XmlValidate
- Year
- YesNoFormat
- ColdFusion Tags
- ColdFusion tag summary
- ColdFusion tags by category
- Application framework tags
- Communications tags
- Database manipulation tags
- Data output tags
- Debugging tags
- Exception handling tags
- Extensibility tags
- File management tags
- Flow-control tags
- Forms tags
- Internet Protocol tags
- Page processing tags
- Security tags
- Variable manipulation tags
- Other tags
- Tags a-b
- Tags c
- Tags f
- cffeed
- cffile
- cffile action = "append"
- cffile action = "copy"
- cffile action = "delete"
- cffile action = "move"
- cffile action = "read"
- cffile action = "readBinary"
- cffile action = "rename"
- cffile action = "upload"
- cffile action = "uploadAll"
- cffile action = "write"
- cffileupload
- cffinally
- cfflush
- cfform
- cfformgroup
- cfformitem
- cfftp
- cfftp: Connection: file and directory operations
- cfftp: Opening and closing FTP server connections
- cfftp : Opening and closing secure FTP server connections
- cfftp action = "listDir"
- cffunction
- Tags g-h
- Tags i
- Tags j-l
- cfjava
- cflayout
- cflayoutarea
- cfldap
- cflocation
- cflock
- cflog
- cflogin
- cfloginuser
- cflogout
- cfloop
- cfloop : conditional loop
- cfloop : index loop
- cfloop : looping over a COM collection or structure
- cfloop : looping over a date or time range
- cfloop : looping over a list, a file, or an array
- cfloop : looping over a query
- Tags m-o
- cfmail
- cfmailparam
- cfmailpart
- cfmap
- cfmapitem
- cfmediaplayer
- cfmenu
- cfmenuitem
- cfmessagebox
- cfmodule
- cfNTauthenticate
- cfoauth
- cfobject
- cfobject: .NET object
- cfobject: COM object
- cfobject: component object
- cfobject: CORBA object
- cfobject: Java or EJB object
- cfobject: web service object
- cfobjectcache
- cfoutput
- Tags p-q
- Tags r-s
- Tags t
- Tags u-z
- CFML Reference
- Reserved words and variables
- Ajax JavaScript functions
- Ajax JavaScript functions
- Function summary Ajax
- ColdFusion.Ajax.submitForm
- ColdFusion.Autosuggest.getAutosuggestObject
- ColdFusion.Layout.enableSourceBind
- ColdFusion.MessageBox.getMessageBoxObject
- ColdFusion.ProgressBar.getProgressBarObject
- ColdFusion.MessageBox.isMessageBoxDefined
- JavaScriptFunctionsinColdFusion9Update1
- ColdFusion ActionScript functions
- ColdFusion mobile functions
- Application.cfc reference
- Script functions implemented as CFCs
- ColdFusion Flash Form style reference
- Styles valid for all controls
- Styles for cfform
- Styles for cfformgroup with horizontal or vertical type attributes
- Styles for box-style cfformgroup elements
- Styles for cfformgroup with accordion type attribute
- Styles for cfformgroup with tabnavigator type attribute
- Styles for cfformitem with hrule or vrule type attributes
- Styles for cfinput with radio, checkbox, button, image, or submit type attributes
- Styles for cftextarea tag and cfinput with text, password, or hidden type attributes
- Styles for cfselect with size attribute value of 1
- Styles for cfselect with size attribute value greater than 1
- Styles for cfcalendar tag and cfinput with dateField type attribute
- Styles for the cfgrid tag
- Styles for the cftree tag
- ColdFusion Flash Form Style Reference
- ColdFusion event gateway reference
- ColdFusion Event Gateway reference
- addEvent
- CFEvent
- CFEventclass
- Constructor
- Gateway development interfaces and classes
- getStatus
- setCFCPath
- setCFCMethod
- getOriginatorID
- getLogger
- getBuddyList
- getBuddyInfo
- IM gateway message sending commands
- IM Gateway GatewayHelper class methods
- onIncomingMessage
- onIMServerMessage
- onBuddyStatus
- onAddBuddyResponse
- onAddBuddyRequest
- IM Gateway CFC incoming message methods
- IM gateway methods and commands
- CFML CFEvent structure
- warn
- info
- setOriginatorID
- data command
- submit Multi command
- submit command
- setGatewayType
- setGatewayID
- setData
- setCFCListeners
- outgoingMessage
- getStatusTimeStamp
- numberOfMessagesReceived
- numberOfMessagesSent
- removeBuddy
- removeDeny
- removePermit
- setNickName
- setPermitMode
- setStatus
- SMS Gateway CFEvent structure and commands
- SMS Gateway incoming message CFEvent structure
- getStatusAsString
- getProtocolName
- getPermitMode
- getPermitList
- getNickName
- getName
- getDenyList
- getCustomAwayMessage
- getQueueSize
- getMaxQueueSize
- getHelper
- getGatewayType
- getGatewayServices
- getGatewayID_1
- getGatewayID
- getData
- getCFCTimeout
- setCFCTimeout
- getCFCPath
- getCFCMethod
- GatewayServices class
- Gateway interface
- GatewayHelper interface
- addPermit
- addDeny
- addBuddy
- error
- debug
- Logger class
- stop
- start
- CFML event gateway SendGatewayMessage data parameter
- restart
- fatal
- SMS gateway message sending commands
- ColdFusion C++ CFX Reference
- ColdFusion Java CFX reference
- WDDX JavaScript Objects
- Cloud services
- ColdFusion and GCP Storage
- ColdFusion and GCP Firestore
- ColdFusion and GCP PubSub
- ColdFusion and Amazon S3
- ColdFusion and DynamoDB
- ColdFusion and Amazon SQS
- ColdFusion and Amazon SNS
- ColdFusion and MongoDB
- ColdFusion and Azure Blob
- ColdFusion and Azure Service Bus
- Multi-cloud storage services
- Multi-cloud RDS databases
- ColdFusion and Azure Cosmos DB
Description
Creates a ColdFusion image. 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.
History
ColdFusion 10: Added the attribute interpolation to {{cfimage action = "resize"}}
ColdFusion 8: Added this tag.
Category
Other tag
Syntax
Add a border to an image <cfimage required action = "border" source = "absolute pathname|pathname relative to the web root|URL|#cfimage variable#" optional color = "hexadecimal value|web color" destination = "absolute pathname|pathname relative to the web root" isBase64 = "yes|no" name = "cfimage variable" overwrite = "yes|no" thickness = "number of pixels"> Create a CAPTCHA image <cfimage required action = "captcha" height = "number of pixels" text = "text string" width = "number of pixels" optional destination = "absolute pathname|pathname relative to the web root" difficulty = "high|medium|low" overwrite = "yes|no" fonts = "comma-separated list of font names" fontSize = "point size"> Convert an image file format <cfimage required action = "convert" destination = "absolute pathname|pathname relative to the web root" source = "absolute pathname|pathname relative to the web root"|URL|#cfimage variable# optional isBase64 = "yes|no" name = "cfimage variable" overwrite = "yes|no"> Retrieve information about an image <cfimage required action = "info" source = "absolute pathname|pathname relative to the web root|URL|#cfimage variable#" structname = "structure name" optional isBase64 = "yes|no"> Read an image into memory <cfimage required name = "cfimage variable" source = "absolute pathname|pathname relative to the web root|URL|#cfimage variable#" optional action = "read" isBase64 = "yes|no"> Resize an image <cfimage required action = "resize" height = "number of pixels|percent%" source = "absolute pathname|pathname relative to the web root|URL|#cfimage variable#" width = "number of pixels|percent%" optional destination = "absolute pathname|pathname relative to the web root" isBase64 = "yes|no" name = "cfimage variable" overwrite = "yes|no"> interpolation = "interpolation algorithm" Rotate an image <cfimage required action = "rotate" angle = "angle in degrees" source = "absolute pathname|pathname relative to the web root|URL|#cfimage variable#" optional destination = "absolute pathname|pathname relative to the web root" isBase64= "yes|no" name = "cfimage variable" overwrite = "yes|no"> Write an image to a file <cfimage required action = "write" destination = "absolute pathname|pathname relative to the web root" source = "absolute or relative pathname|URL|#cfimage variable#" optional isBase64= "yes|no" overwrite = "yes|no" quality = "JPEG image quality"> Write an image to the browser <cfimage required action = "writeToBrowser" source = "absolute pathname|pathname relative to the web root|URL|#cfimage variable#" optional format = "png|jpg|jpeg" isBase64= "yes|no">
You can specify this tag's attributes in an attributeCollection attribute whose value is a structure. Specify the structure name in the attributeCollection attribute and use the tag's attribute names as structure keys.
See also
ImageAddBorder, ImageCreateCaptcha, ImageInfo, ImageNew, ImageRead, ImageReadBase64,ImageResize, ImageRotate, ImageWrite, ImageWriteBase64, Creating and Manipulating ColdFusion Images in the Developing ColdFusion Applications
Attributes
Attribute |
Action |
Req/Opt |
Default |
Description |
---|---|---|---|---|
action |
N/A |
Optional |
read |
Action to take. Must be one of the following:
|
angle |
rotate |
Required |
|
Angle in degrees to rotate the image.Specify an integer for the value. |
color |
border |
Optional |
black |
Border color.Hexadecimal value or supported named color; see the name list in Valid HTML named colors section. For a hexadecimal value, use the form "##xxxxxx" or "xxxxxx", where x = 0-9 or A-F; use two number signs or none. |
destination |
border captcha |
Optional (see Description) |
|
Absolute or relative pathname where the image output is written. The image format is determined by the file extension.
|
difficulty |
captcha |
Optional |
low |
Level of complexity of the CAPTCHA text. Specify one of the following levels of text distortion:
|
fonts |
captcha |
Optional |
|
One or more valid fonts to use for the CAPTCHA text. Separate multiple fonts with commas. If the specified font is not available, falls back to system fonts. |
fontSize |
captcha |
Optional |
24 |
Font size of the text in the CAPTCHA image. |
format |
writeToBrowser |
Optional |
PNG |
Format of the image displayed in the browser. If you do not specify a format, the image is displayed in PNG format. |
height |
captcha resize |
Required |
|
Height in pixels of the image. |
inter |
resize |
Optional |
highest |
Specify a specific interpolation algorithm by name (for example, hamming), by image quality (for example,mediumQuality), or by performance (for example, highestPerformance). The following are the valid values:
|
isBase64 |
border |
Optional |
no |
Specifies whether the source is a Base64 string:
|
name |
border |
Optional |
|
Name of the ColdFusion image variable to create. |
overwrite |
border |
Optional |
no |
Valid only if the destination attribute is specified. The overwrite values are:
|
quality |
write |
Optional |
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). |
source |
border |
Required |
|
|
struct |
info |
Required |
|
Name of the ColdFusion structure to be created. |
text |
captcha |
Required |
|
Text string displayed in the CAPTCHA image. Use capital letters for better readability. Do not include spaces because users cannot detect them in the resulting CAPTCHA image. |
thickness |
border |
Optional |
1 |
Border thickness in pixels. The border is added to the outside edge of the source image, increasing the image area accordingly. |
width |
captcha |
Required |
|
Width in pixels of the image. |
Usage
ColdFusion provides the cfimage tag and the ColdFusion image, a construct native to ColdFusion that contains image data. You can manipulate ColdFusion images in memory and write them to a file, a database, or directly to a browser. You use the cfimage tag to create ColdFusion images from existing image files and perform simple image actions, such as rotating or resizing. Alternatively, you can use theImageNew function to create a ColdFusion image from the beginning or from an existing image. You can use the Image functions to perform complex image manipulation operations on ColdFusion images that you create with the cfimage tag or with the ImageNew function.
You can perform the following tasks with ColdFusion images:
- Convert an image from one file format to another. For example, you can convert a BMP file to a JPEG file or a Base64 string to a GIF.
- Enforce consistent sizes on files uploaded to the server.
- Enforce size limits on JPEG images (by changing the quality of the image).
- Save a ColdFusion image to a file or write the image directly to a browser.
- Use the ImageGetBlob function within the cfquery tag to insert a ColdFusion image as a Binary Large Object Bitmap (BLOB) in a database. Also, you can extract a BLOB from a database and generate a ColdFusion image from it.
- Create watermark images.
- Create thumbnail images.
- Create a Completely Automated Public Turing test to tell Computers and Humans Apart (CAPTCHA) image, a distorted text image that is human-readable, but not machine-readable, used in a challenge-response test for preventing spam.
For more detailed examples, see Creating and Manipulating ColdFusion Images in the Developing ColdFusion Applications.
File attributes
Use the following syntax to specify an in-memory file, which is not written to disk in the destination and source attributes. In-memory files speed processing of transient data.
ram:///filepath
The filepath can include directories, for example ram:///petStore/images/poodle.jpg. Create the directories in the path before you specify the file. For more information on using in-memory files, see Working with in-memory files in Optimizing ColdFusion applications in the Developing ColdFusion Applications.
Supported image file formats
The cfimage tag operates on a number of different file formats. To list the formats that are supported on the server where the ColdFusion application is deployed, use the GetReadableImageFormats function and the GetWriteableImageFormats function.ColdFusion supports the following default image formats on Macintosh, Windows, and Unix operating systems:
- JPEG
- GIF
- TIFF
- PNG
- BMP
ColdFusion does not support the following image formats: - Animated GIF
- Multipage TIFF
- PSD
- AI
CMYK support
The cfimage tag supports reading and writing CMYK images, but does not support actions that require converting the images. For example, you can use CMYK images with the read, write, writeToBrowser, resize, rotate, and info actions. You cannot use CMYK images with the convert, captcha, and border actions. The same rule applies to image functions. For example, the ImageNew, ImageRead, and ImageWrite functions support CMYK images, but the ImageAddBorder function does not.
Valid HTML named colors
The following table lists the W3C HTML 4 named color value or hexadecimal values that the color attribute accepts:
Color name |
RGB value |
---|---|
Black |
##000000 |
Blue |
##0000FF |
Red |
##FF0000 |
Gray |
##808080 |
LightGray |
##D3D3D3 |
DarkGray |
##A9A9A9 |
Green |
##008000 |
Pink |
##FFC0CB |
Cyan |
##00FFFF |
Magenta |
##FF00FF |
Orange |
##FFA500 |
White |
##FFFFFF |
Yellow |
##FFFF00 |
For all other color values, enter the hexadecimal value. Enter a six-digit value, which specifies the RGB value. Values between 00 and FF are allowed.
Image quality
By default, the cfimage tag generates images with antialiasing turned on (to remove the appearance of jagged edges). The interpolation method is set to highestQuality: this produces a high-quality image, but decreases processing speed. To turn off antialiasing, use the ImageSetAntialiasing function. To change the interpolation method or for more control over image attributes, use the following functions:
border action Use the border action to create a rectangular border around the outer edge of an image. You can control the thickness of the border and its color. For more control, use the ImageAddBorder function. The following example shows how to set the thickness and color of a border:
<!--- This example shows how to create a ColdFusion image from an existing JPEG file, add a five-pixel-wide red border to the image, and save it to a new JPEG file. ---> <cfimage source="../cfdocs/images/artgallery/jeff05.jpg" action="border" thickness="5" destination="jeff05.jpg" color="red" overwrite="yes">
- captcha action Use the captchaaction to create a distorted text image that is human-readable but not machine-readable. When you create a CAPTCHA image, you specify the text that is displayed in the CAPTCHA image; ColdFusion randomly distorts the text. You can specify the height and width of the text area, which affects the spacing between letters, the font size, the fonts used for the CAPTCHA text, and the level of difficulty, which affects readability. The following example shows how to write a CAPTCHA image directly to the browser:
<cfimage action="captcha" fontSize="25" width="400" height="150" text="rEadMe" fonts="Arial,Verdana,Courier New">
ColdFusion supports CAPTCHA images in PNG format only.
Use unique names for the CAPTCHA image files so that when multiple users access the CAPTCHA images, the files are not overwritten. |
The following example shows how to create CAPTCHA images with a medium level of difficulty that are written to files:
<!--- Use the GetTickCount function to generate unique names for the CAPTCHA files. ---> <cfset tc = GetTickCount()> <cfimage action="captcha" fontSize="15" width="180" height="50" text="rEadMe" destination="images/rEadMe#tc#.png" difficulty="medium">
For a detailed example, see the Creating and Manipulating ColdFusion Images in the Developing ColdFusion Applications.
- convert action Use the convertaction to convert an image from one file format to another. For more information on file formats, see the section Supported image file formats. The following example shows how to convert a JPEG file to a PNG file:
<!--- This example shows how to convert a JPEG image to a PNG image. ---> <cfimage source="../cfdocs/images/artgallery/aiden02.jpg" action="convert" destination="aiden02.png">
Converting images between one file format to another is time-consuming. Also, image quality can degrade; for example, PNG images support 24-bit color, but GIF images support only 256 colors. Converting transparent images (images with alpha) can degrade image quality.
- info action Use the info action to create a ColdFusion structure that contains information about the image, including the color model, height, width, and source of the image. The structure is the same as returned by the ImageInfo function. The following example shows how to retrieve all of the information about an image:
<!--- This example shows how to retrieve and display image information. ---> <cfimage source="../cfdocs/images/artgallery/viata03.jpg" action="info" structName="viatoInfo"> <cfdump var="#viatoInfo#"> <!--- Alternatively, you can use the cfoutput tag to display specific image information, as shown in the following example. ---> <cfoutput> <p>height: #viatoInfo.height# pixels</p> <p>width: #viatoInfo.width# pixels</p> <p>source: #viatoInfo.source#</p> <p>transparency: #viatoInfo.colormodel.transparency#</p> <p>pixel size: #viatoInfo.colormodel.pixel_size#</p> <p>color model: #viatoInfo.colormodel.colormodel_type#</p> <p>alpha channel support: #viatoInfo.colormodel.alpha_channel_support#</p> <p>color space: #viatoInfo.colormodel.colorspace#</p> </cfoutput>
- read action Use the read action to read an image from the specified local file pathname or URL, and create a ColdFusion image in memory. You can use the ColdFusion image variable as the source for another cfimage tag or for Image functions. The read action performs the same operation as the ImageRead function. The following example shows how to create a ColdFusion image from a JPEG file and manipulate it using the ImageGrayscalefunction:
<!--- This code shows how to create a ColdFusion image from a JPEG file. ---> <cfimage source="../cfdocs/images/artgallery/jeff01.jpg" name="myImage"> <!--- This code shows how to convert the image to grayscale. ---> <cfset ImageGrayscale(myImage)> <!--- This code shows how to write the grayscale image to a JPEG file. ---> <cfimage source="#myImage#" action="write" destination="myGrayscaleImage.jpg" overwrite="yes">
- resize action Use the resizeaction to resize an image to the specified height and width. You can specify the height and width in pixels or as a percentage:
<!--- This example shows how to specify the height and width of an image in pixels. ---> <cfimage source="../cfdocs/images/artgallery/jeff01.jpg" action="resize" width="100" height="100" destination="jeff01_thumbnail.jpg" overwrite="yes"> <!--- This example shows how to specify the height and width of an image as percentages. ---> <cfimage source="../cfdocs/images/artgallery/jeff02.jpg" action="resize" width="50%" height="50%" destination="jeff02_thumbnail.jpg" overwrite="yes"> <!--- This example shows how to specify the height of an image in pixels and its width as a percentage. ---> <cfimage source="../cfdocs/images/artgallery/jeff03.jpg" action="resize" width="50%" height="100" destination="jeff03_thumbnail.jpg" overwrite="yes">
For more control of resize attributes, use the ImageResize function.
rotate action Use the rotateaction to rotate an image by degrees:
<!--- This example shows how to rotate an image by 30 degrees. ---> <cfimage source="../cfdocs/images/artgallery/maxwell01.jpg" action="rotate" angle="30" name="maxwellAngle"> <!--- Display the rotated image in a browser. ---> <cfimage source="#maxwellAngle#" action="writeToBrowser">
For more control of the rotate attributes, use the ImageRotate function.
- write action Use the write action to write an image to the specified path. The new image is converted to the file type specified in the destination attribute. The write action performs the same operation as the ImageWrite function. When you write an image to a JPEG file, the image quality is set to 75% of the original image by default. To control the image size, use the quality attribute of the write action.
You can use the write action to change the quality of a JPEG image to reduce file size. The following example shows how to change image quality to .5:
<!--- This example shows how to create a PNG file from a JPEG file by using the write action. ---> <cfimage source="../cfdocs/images/artgallery/aiden01.jpg" action="write" destination="aiden01.png"> <!--- This example shows how to create a low-quality JPEG image. ---> <cfimage source="../cfdocs/images/artgallery/jeff05.jpg" action="write" destination="jeff05_lq.jpg" quality=".5"> <!--- This example shows how to write a JPEG file to a new location. ---> <cfimage source="../cfdocs/images/artgallery/jeff05.jpg" action="write" destination="jeff05.jpg">
- writeToBrowser action Use the writeToBrowseraction to display one or more ColdFusion images directly to the browser without writing them to files. Images are displayed in PNG format. The following example shows how to reduce the size of an image and display it in the browser:
<!--- This example shows how to create a ColdFusion image from a JPEG file, resize it, and then display it in the browser as a PNG image. ---> <cfimage source="../cfdocs/images/artgallery/jeff05.jpg" action="resize" width="50%" height="50%" name="smLogo"> <cfimage source="#smLogo#" action="writeToBrowser">
Example
This example shows how to create a ColdFusion image and manipulate it by using Image functions:
<!--- Create the ColdFusion image variable "myImage" from a JPEG file. ---> <cfimage source="../cfdocs/images/artgallery/jeff05.jpg" name="myImage"> <!--- Pass the ColdFusion image to the Image functions to blur the image by a radius of 5, flip the image 90 degrees, and convert the image to grayscale. ---> <cfset ImageBlur(myImage,5)> <cfset ImageFlip(myImage,"90")> <cfset ImageGrayscale(myImage)> <!--- Write the transformed image to a browser. ---> <cfimage source="#myImage#" action="writeToBrowser">