cf_image_resize is a quick solution to resize an image easily, on-the-fly. Using built-in Java provided by CFMX, this custom tag requires no CFX installation. Just put the custom tag on the working directory, and you're on!
New in V2: Better support for GIF and PNG files which have alpha layer (transparent). Better error handling. CF_Image_Resize will now throws an error whenever incorrect parameter was supplied. The caller page can trap the error message in <cftry><cfcatch> block.
New in V3: Support ColdFusion 8
*** Requirements: ColdFusion MX and up
*** Usage:
| <cf_image_resize |
InputImageFile="Full path and filename for the image to be resized (mandatory). Accepted format: jpg, png, gif" |
| |
OutputImageFile="Full path and filename for resulting image (mandatory). Allowable format: jpg, png" |
| |
ToWidth="Exact width of the resulting image. 0 means proportional resize based on ToHeight" |
| |
ToHeight="Exact height of the resulting image. 0 means proportional resize based on ToWidth" |
| |
MaxWidth="Maximum width of the resulting image. 0 means proportional resize based on MaxHeight" |
| |
MaxHeight="Maximum height of the resulting image. 0 means proportional resize based on MaxWidth" |
| |
Quality="JPEG compression quality (0-100) 0 is the worst quality while 100 has the best quality" |
| |
IfInputLargerOnly="Set the resizing engine to resize only if InputImageFile is larger than MaxWidth and MaxHeight (1/0)"> |
Explanation: 1. ToWidth and ToHeight determine the exact size of resulting image. You can specify these values as pixels or as percentage. For example: Towidth="100" or Towidth="50%" To resize proportionally you can set these values to the same percentage value. 2. MaxWidth and MaxHeight determine the maximum size of resulting image, in pixels. You will these attributes if you want the resulting image to have a specific maximum width or height. For example: If you put towidth="50%" and toheight="50%" and the original image size is 1000x1000 pixels, the resulting image will be 500x500 pixels. But if you want the max image to be 100x200, then you can set MaxWidth="100 and MaxHeight="200", and the resulting image will be resized proportionally based on those maximum values. 3. IfInputLargerOnly Set this value to "yes" or "true" or "1" and specify MaxWidth and MaxHeight if you want to resize the original image only if the original image is larger than MaxWidth and MaxHeight. If the original image is smaller than MaxWidth and MaxHeight, the resulting image will be the same like the input image.
4. New in v1.1 Another way to set proportional resize is to put 0 either in ToWidth/ToHeight or MaxWidth/MaxHeight. Eg: ToWidth=0 ToHeight=100 will set the resulting image to 100px tall, and the wide will be resized proportionally. Eg: MaxWidth=300 ToHeight=0 will set the resulting image to maximum 300px wide, and the height will be resized proportionally.
5. New in V2: Better support for GIF and PNG files which have alpha layer (transparent). Better error handling. CF_Image_Resize will now throws an error whenever incorrect parameter was supplied.
*** Examples: For a complete usage example, please browse: http://www.masrizal.com/index.cfm?fuseaction=idea.download_detail&ProductID=cf_image_resize
|