imageAddBorder

Adds a rectangular border around the outside edge of a ColdFusion image.

imageAddBorder(name, thickness [, color] [, bordertype]) → returns void

Member Function Syntax

someImage.addBorder(thickness [, color] [, bordertype])

Argument Reference

name string
Required

The image on which this operation is performed.

thickness string
Required

Thickness of the border in pixels. The default value is 1. The border is added to the outside edge of the image; the image area is increased accordingly.

color string
Default: black

Only valid if the borderType is not specified or if borderType = 'constant'.

bordertype string
Default: constant

The type of border.
Values:
  • zero
  • constant
  • copy
  • reflect
  • wrap

Examples
Sample code invoking the imageAddBorder function

Draw a green border around the outside edge of the red border.

<cfset imageAddBorder(myImage,5,"green")>    

Add a 50-pixel-wide border to the outside edge of the image that is a tiled version of the image itself.

<cfset imageAddBorder(myImage,50,"","wrap")>    

Create the border.

<cfset imageAddBorder(myImage,100,"","reflect")> 

Create a ColdFusion image from an existing JPEG file.

<cfset imageAddBorder(myImage,100,"","copy")>  

CF 11+ Lucee 4.5+ Add border with optional color parameter

imgObj = imageRead("http://cfdocs.org/apple-touch-icon.png");
imgObj.addBorder(5,"005100");
cfimage(action="writeToBrowser", source=imgObj);

Signup for cfbreak to stay updated on the latest news from the ColdFusion / CFML community. One email, every friday.

Fork me on GitHub