Adobe ColdFusion 8

ImageAddBorder

Description

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

Returns

Nothing.

Category

Image functions

Function syntax

ImageAddBorder(name, thickness [, color, borderType])

See also

cfimage, ImageDrawRect, IsImageFile

History

ColdFusion 8: Added this function.

Parameters

Parameter

Description

name

Required. The ColdFusion image on which this operation is performed.

thickness

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

Optional. Border color. The default border color is black. See Usage.

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

borderType

Optional. The type of border:

  • zero: Sets the border color to black.
  • constant: Sets the border to the specified color (default).
  • copy: Sets sample values to copies of the nearest valid pixel. For example, pixels to the left of the valid rectangle assume the value of the valid edge pixel in the same row. Pixels both above and to the left of the valid rectangle assume the value of the upper-left pixel.
  • reflect: Mirrors the edges of the source image. For example, if the left edge of the valid rectangle is located at x = 10, pixel (9, y) is a copy of pixel (10, y) and pixel (6, y) is a copy of pixel (13, y).
  • wrap: Tiles the source image in the plane.

Usage

The thickness of the border is specified in pixels by the thickness parameter. The thickness cannot be less than 0.

For the color value, specify a hexadecimal value or supported named color; see the name list in Valid HTML named colors. For a hexadecimal value, use the form "##xxxxxx" or "xxxxxx", where x = 0-9 or A-F; use two number signs or none.

Example

Example 1

<!--- This example shows how to create a 10-pixel-wide red border around an image with a 5-pixel-wide green border around the red border.--->
<!--- Create a ColdFusion image from an existing JPEG file. --->
<cfimage source="../cfdocs/images/artgallery/jeff05.jpg" name="myImage">
<!--- Draw a red border around the outside edge of the image. --->
<cfset ImageAddBorder(myImage,10,"red")>
<!--- Draw a green border around the outside edge of the red border. --->
<cfset ImageAddBorder(myImage,5,"green")>
<!--- Save the modified ColdFusion image to a file. --->
<cfimage source="#myImage#" action="write" destination="test_myImage.jpeg" overwrite="yes">
<!--- Display the source image and the new image. --->
<img src="../cfdocs/images/artgallery/jeff05.jpg"/>
<img src="test_myImage.jpeg"/>

Example 2

<!--- This example shows how to create a border from the tiled image. --->
<!--- Create a ColdFusion image from an existing JPEG file. --->
<cfimage source="../cfdocs/images/artgallery/lori05.jpg" name="myImage">
<!--- 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")>
<!--- Save the modified ColdFusion image to a file. --->
<cfimage source="#myImage#" action="write" destination="test_myImage.jpeg" overwrite="yes">
<!--- Display the source image and the new image. --->
<img src="../cfdocs/images/artgallery/lori05.jpg"/>
<img src="test_myImage.jpeg"/>

Example 3

<!--- This example shows how to create a 100-pixel-wide border that is a mirror of the source image. --->
<!--- Create a ColdFusion image from an existing JPEG file. --->
<cfimage source="../cfdocs/images/artgallery/maxwell01.jpg" name="myImage">
<!--- Create the border. --->
<cfset ImageAddBorder(myImage,100,"","reflect")>
<!--- Save the modified ColdFusion image to a file. --->
<cfimage source="#myImage#" action="write" destination="test_myImage.jpeg" overwrite="yes">
<!--- Display the source image and the new image. --->
<img src="../cfdocs/images/artgallery/maxwell01.jpg"/>
<img src="test_myImage.jpeg"/>

Example 4

<!--- This example shows how to copy 100 pixels from the outer edge of the image and create a border from it. --->
<!--- Create a ColdFusion image from an existing JPEG file. --->
<cfimage source="../cfdocs/images/artgallery/jeff05.jpg" name="myImage">
<cfset ImageAddBorder(myImage,100,"","copy")>
<!--- Save the modified ColdFusion image to a file. --->
<cfimage source="#myImage#" action="write" destination="test_myImage.jpeg" overwrite="yes">
<!--- Display the source image and the new image. --->
<img src="../cfdocs/images/artgallery/jeff05.jpg"/>
<img src="test_myImage.jpeg"/>