imagePaste

Takes two images and an (x,y) coordinate and draws the second image over the first image with the upper-left corner at coordinate (x,y).

imagePaste(image1, image2, x, y) → returns void

Member Function Syntax

someImage.paste(image2, x, y)

Argument Reference

image1 string
Required

The bottom image.

image2 string
Required

The image that is pasted on top of image1.

x numeric
Required

The x coordinate where the upper-left corner of image2 is pasted.

y numeric
Required

The y coordinate where the upper-left corner of image2 is pasted.

Examples
Sample code invoking the imagePaste function

This example shows how to copy a small rectangular area of one image and paste it over a larger image.

<!--- Create a ColdFusion image from an existing JPEG file and name it "myImage1". ---> 
 <cfimage source="../cfdocs/images/artgallery/jeff05.jpg" name="myImage1"> 
 <!--- Create a ColdFusion image from an existing JPEG file and name it "myImage2". ---> 
 <cfimage source="../cfdocs/images/artgallery/maxwell01.jpg" name="myImage2"> 
 <!--- Copy a rectangular region of myImage1. ---> 
 <cfset resImage = imageCopy(myImage1,1,1,50,50)> 
 <!--- Paste the rectangular area over myImage2. ---> 
 <cfset imagePaste(myImage2,resImage,100,100)> 
 <!--- Write the second ColdFusion image to result.jpg. ---> 
 <cfimage source="#myImage2#" action="write" destination="test_myImage.jpg" overwrite="yes"> 
 <!--- Display the two source images and the new image. ---> 
 <img src="../cfdocs/images/artgallery/jeff05.jpg"/> 
 <img src="../cfdocs/images/artgallery/maxwell01.jpg"/> 
 <img src="test_myImage.jpg"/> 

CF 11+ Lucee 4.5+ Copy the center of the image, rotate it 180 degrees about its center and paste it back into the original image

imgObj = imageRead("http://cfdocs.org/apple-touch-icon.png");
copiedImgObj = imgObj.copy(50,50,50,50);
copiedImgObj.rotate(25,25,180,"bicubic");
imgObj.paste(copiedImgObj,50,50);
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