ImageCFC: Documentation: Method Description

imageCFC.watermark()

Description

adds text to an image.

Returns

A structure containing the following fields:

keyvalue
errorCode0 for success, non-zero for failure. Always returned, but not really used if the throwOnError option is set to true.
errorMessageA description of the error. Always returned, but not really used if the throwOnError option is set to true.
imgA java BufferedImage object is returned if no output file is specified

Function Syntax

watermark(objImage1,objImage2,inputFile1,inputFile2,alpha,placeAtX,placeAtY,outputFile,jpegCompression)

ParameterRequired?DefaultDescription
objImage1 YES - A java image object, or a blank string.
objImage2 YES - A java image object to be watermarked on the original image, or a blank string.
inputFile1 YES - File path or URL to an image, or a blank string.
inputFile2 YES - File path or URL to an image to be watermarked on the original image, or a blank string.
alphpa YES - Alpha transparency value of the watermark image. 0.0 = invisible, 1.0 = not transparent at all.
placeAtX YES - X coordinate where the upper left corner of the watermarked image will be placed.
placeAtY YES - Y coordinate where the upper left corner of the watermarked image will be placed.
outputFile YES - File path to write the output, or a blank string.
jpegCompression NO defaultJpegCompression jpeg compression quality to use if writing a jpeg file. 0-100. 100 is the highest quality.

For each element of the water mark (the base image and the overlay), you must supply either an image object or a file path to a source image.

Example

This example takes "myimage.jpg", and places "featuer.gif" on top of it as an overlay with 50% transparency, and writes the results to "watermarked.jpg".

<cfset results1 = imageCFC.watermark(
	"", "", <!--- original image and watermark image objects --->
	"C:\Inetpub\wwwroot\myimage.jpg",  <!--- original image file --->
	"C:\Inetpub\wwwroot\feather.gif", <!--- watermark image file --->
	0.5, <!--- alpha level (0 = invisible, 1 = solid) --->
	50, 50, <!--- X and Y location of watermarked image. --->
	"C:\Inetpub\wwwroot\watermarked.jpg" <!--- output image file --->
	)>