ImageResize(image, width, height [, interpolation, blurFactor])
See also
cfimage, ImageSetAntialiasing, ImageScaleToFit, IsImageFile
History
ColdFusion (2018 release): Introduced named parameters.
ColdFusion 8: Added this function.
Parameters
Parameter |
Description |
---|---|
image |
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. |
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:
|
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). The valid range of blur factor is between 0-10. |
Usage
You 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
Interpolation algorithms
Interpolation 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, |
Medium quality image with medium performance |
|
blackman, bessel |
Slightly distorted image quality with high performance |
highestPerformance |
nearest, bicubic, bilinear |
Poor image quality with |
Example
<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"/>