
973
DEVELOPING
COLDFUSION 9 APPLICATIONS
Working with Documents, Charts, and Reports
Las
t
upda
te
d 8/5/2010
<!--- This example shows how to resize an image to a 100-pixel square, while maintaining the
aspect ratio of the source image. --->
<cfimage source="../cfdocs/images/artgallery/jeff05.jpg" name="myImage" action="read">
<!--- Turn on antialiasing. --->
<cfset ImageSetAntialiasing(myImage)>
<cfset ImageScaleToFit(myImage,100,100,"mediumQuality")>
<!--- Display the modified image in a browser. --->
<cfimage source="#myImage#" action="writeToBrowser">
To fit an image in a defined rectangular area, specify the width and height of the rectangle, as the following example
shows:
<!--- This example shows how to resize an image to fit in a rectangle that is 200 pixels
wide and 100 pixels high, while maintaining the aspect ratio of the source image. --->
<cfimage source="../cfdocs/images/artgallery/jeff05.jpg" name="myImage">
<!--- Turn on antialiasing. --->
<cfset ImageSetAntialiasing(myImage)>
<cfset ImageScaleToFit(myImage,200,100)>
<!--- Display the modified image in a browser. --->
<cfimage source="#myImage#" action="writeToBrowser">
In this example, the width of the resulting image is less than or equal to 200 pixels and the height of the image is less
than or equal to 100 pixels.
Also, you can specify just the height or just the width of the rectangle. To do so, specify an empty string for the
undefined dimension. The following example resizes the image so that the width is exactly 200 pixels and the height
of the image is proportional to the width:
<!--- This example shows how to resizes an image so that it is 200 pixels wide, while
maintaining the aspect ratio of the source image. The interpolation method is set to
maximize performance (which reduces image quality). --->
<cfimage source="../cfdocs/images/artgallery/jeff05.jpg" name="myImage">
<!--- Turn on antialiasing. --->
<cfset ImageSetAntialiasing(myImage)>
<cfset ImageScaleToFit(myImage,200,"","highestPerformance")>
<!--- Display the modified image in a browser. --->
<cfimage source="#myImage#" action="writeToBrowser">
For more information, see ImageScaleToFit in the
CFML Reference
.
Creating watermarks
A
watermark
is a semitransparent image that is superimposed on another image. One use for a watermark is for
protecting copyrighted images. To create a watermark in ColdFusion, you use the
ImageSetDrawingTransparency
function with the
ImagePaste
function. You can create a watermark image in one of three ways:
•
Create a watermark from an existing image file. For example, you can use a company logo as a watermark.
•
Create a text image in ColdFusion and apply the image as a watermark. For example, you can create a text string,
such as
Copyright
or
PROOF
and apply it to all the images in a photo gallery.
•
Create a drawing image in ColdFusion and use it as a watermark. For example, you can use the drawing functions
to create a green check mark and apply it to images that have been approved.
Creating a watermark from an image file
The following example shows how to create a watermark from an existing GIF image located on a website:
Содержание COLDFUSION 9
Страница 1: ...Developing Applications ADOBE COLDFUSION 9...