|
DescriptionResizes
a ColdFusion image.
Function syntaxImageResize(name, width, height [, interpolation, blurFactor])
HistoryColdFusion
8: Added this function.
Parameters
Parameter
|
Description
|
name
|
Required. The ColdFusion image on which
this operation is performed.
|
width
|
Required. New width of the ColdFusion image.
If
this value is blank, the width is calculated proportionately to
the height.
|
height
|
Required. New height of the ColdFusion image.
If
this value is blank, the height is calculated proportionately to
the width.
|
interpolation
|
Optional. The interpolation method for resampling.
You can specify a specific interpolation algorithm by name (for
example, hamming), by image quality (for example, mediumQuality),
or by performance (for example, highestPerformance).
Valid values are:
highestQuality (default)
highQuality
mediumQuality
highestPerformance
highPerformance
mediumPerformance
nearest
bilinear
bicubic
bessel
blackman
hamming
hanning
hermite
lanczos
mitchell
quadratic
See Interpolation
algorithms in the Usage section for more information.
|
blurFactor
|
Optional. The blur factor used for resampling.
The higher the blur factor, the more blurred the image (also, the
longer it takes to resize the image). This value must be from 1
through 10.
|
UsageYou can
use this function to enlarge an image or create a thumbnail image.
To
specify the height or width in pixels, enter the integer, for example,
100. To specify the height or width as a percentage, enter the percentage
followed by the percent symbol, for example, 50%.
To resize
an image by one dimension (for example, height), specify the height and
leave width value blank (""). ColdFusion calculates
the width proportionally to the height.
Use the ImageSetAntialiasing function
to improve the quality of the rendered image.
Interpolation algorithmsInterpolation algorithms let you fine-tune
how images are resampled. Each algorithm balances image quality
against performance: in general, the higher the image quality, the
slower the performance. Quality and performance differ based on
image type and the size of the source file. The following table
describes the algorithms and their named equivalents based on average
test results:
Value
|
Named equivalents
|
Description
|
highestQuality (default)
|
lanczos
|
Highest image quality with low performance
|
highQuality, mediumPerformance
|
mitchell, quadratic
|
Good image quality with slightly higher
performance
|
mediumQuality, highPerformance
|
hamming, hanning, hermite
|
Medium quality image with medium performance
|
|
blackman, bessel
|
Slightly distorted image quality with high
performance
|
highestPerformance
|
nearest, bicubic, bilinear
|
Poor image quality with highest performance
|
Example<!--- This example shows how to resize an image to 50% of original size and resize it proportionately to the new width. Notice that the height is blank.--->
<cfset myImage=ImageNew("http://www.google.com/images/logo_sm.gif")>
<cfset ImageResize(myImage,"50%","","blackman",2)>
<!--- Save the modified image to a file called "test_myImage.jpeg" and display the image in a browser. --->
<cfimage source="#myImage#" action="write" destination="test_myImage.jpeg" overwrite="yes">
<!--- Display the source image and the thumbnail image. --->
<img src="http://www.google.com/images/logo_sm.gif"/>
<img src="test_myImage.jpeg"/>
|
|
|