User Guide Cancel

ImageRotate

 

Description

Rotates a ColdFusion image at a specified point by a specified angle.

Returns

Nothing.

Category

Image functions

Function syntax

ImageRotate(name, angle [,interpolation])
ImageRotate(name, x , y , angle [,interpolation])
ImageRotate(name, angle [,interpolation]) ImageRotate(name, x , y , angle [,interpolation])
ImageRotate(name, angle [,interpolation])
ImageRotate(name, x , y , angle [,interpolation])

See also

cfimageImageFlipImageSetAntialiasingIsImageFile

History

ColdFusion 8: Added this function.

Parameters

Parameter

Description

name

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

angle

Required. The rotation angle in degrees.

x

Required. The x coordinate for the point of rotation.

y

Required. The y coordinate for the point of rotation.

interpolation

Optional. Type of interpolation:

  • nearest: Applies the nearest neighbor method of interpolation. Image quality is lower than the other interpolation methods, but processing is fastest (default). In this interpolation method, the new value of a cell is taken from the cell that is closest to the original cell.
  • bilinear: Applies the bilinear method of interpolation. The quality of the image is less pixelated than the default, but processing is slower. This method assigns the weighted value of the four surrounding cells to the new cell.
  • bicubic: Applies the bicubic method of interpolation. Generally, the quality of image is highest with this method and processing is slowest. This method uses the weighted value of the 16 surrounding cells to the new cell.

Usage

Specify both the x and the y coordinates or neither. If you do not specify the x and y coordinates, the point of rotation is the center of the image, which is the default position. Use the ImageSetAntialiasing function to improve the quality of the rendered image.

Example

Example 1

<!--- Create a ColdFusion image from an existing JPEG file. --->
<cfset myImage=ImageNew("../cfdocs/images/artgallery/jeff05.jpg")>
<cfset ImageSetAntialiasing(myImage,"on")>
<!--- Rotate the image by 10 degrees. --->
<cfset ImageRotate(myImage,10)>
<cfimage source="#myImage#" action="writeToBrowser">
<!--- Create a ColdFusion image from an existing JPEG file. ---> <cfset myImage=ImageNew("../cfdocs/images/artgallery/jeff05.jpg")> <cfset ImageSetAntialiasing(myImage,"on")> <!--- Rotate the image by 10 degrees. ---> <cfset ImageRotate(myImage,10)> <cfimage source="#myImage#" action="writeToBrowser">
<!--- Create a ColdFusion image from an existing JPEG file. --->
<cfset myImage=ImageNew("../cfdocs/images/artgallery/jeff05.jpg")>
<cfset ImageSetAntialiasing(myImage,"on")>
<!--- Rotate the image by 10 degrees. --->
<cfset ImageRotate(myImage,10)>
<cfimage source="#myImage#" action="writeToBrowser">

Example 2

<cfimage source="../cfdocs/images/artgallery/jeff05.jpg" name="myImage">
<cfset ImageRotate(myImage,10,90,10,"bicubic")>
<cfimage source="#myImage#" destination="testMyImage.jpeg" action="write" overwrite="yes">
<img src="../cfdocs/images/artgallery/jeff05.jpg">
<img src="testMyImage.jpeg">
<cfimage source="../cfdocs/images/artgallery/jeff05.jpg" name="myImage"> <cfset ImageRotate(myImage,10,90,10,"bicubic")> <cfimage source="#myImage#" destination="testMyImage.jpeg" action="write" overwrite="yes"> <img src="../cfdocs/images/artgallery/jeff05.jpg"> <img src="testMyImage.jpeg">
<cfimage source="../cfdocs/images/artgallery/jeff05.jpg" name="myImage">
<cfset ImageRotate(myImage,10,90,10,"bicubic")>
<cfimage source="#myImage#" destination="testMyImage.jpeg" action="write" overwrite="yes">
<img src="../cfdocs/images/artgallery/jeff05.jpg">
<img src="testMyImage.jpeg">

Get help faster and easier

New user?