These instructions are also available in pdf format. We recommend using the PDF version if a printable manual is required.
This Cold Fusion custom tag resizes JPG images. It takes a source image from disk and either applies a scale factor or resizes by specifying a new height, width or both. The amount of JPG compression can also be set. The resulting image is saved to disk after resizing.
This tag is only suitable for use when the server is running on a Windows platform.
Before use, register the tag in the ColdFusion Administrator by selecting Extensions, CFX Tags and "Register C++ CFX". The tag name is "cfx_JpegResize" and the path to the DLL file should be entered in the box marked "Server Library (.dll)", or by using the "Browse Server" button.
<cfx_jpegresize action = "resize" or "scale"
source = "physical_path_and_filename_of_source_image"
filename = "physical_path_and_filename_of_new_image"
quality = "jpeg_quality_between_1_and_100"
factor = "scale_factor"
width = "new_width"
height = "new_height">
|action||Required. One of the following:
resize - specify a new height, width or both.
scale - apply a scale factor as a percentage.
|source||Required. The full physical path and file name to the JPG file that is to be resized.|
|filename||Required. The full phyical path and file name where the new file will be saved.|
|quality||Optional. A number between 1 and 100 that defines quality/compression of the new image. A high number is a high quality, large file size. Defaults to 90 if unspecified.|
|factor||Required if action is scale. Factor is the percentage scaling applied to the image, 100 is unchanged.|
|width||Optional. The new width in pixels when action is resize. If unspecified or zero the new width is calculated from the height attribute, maintaining aspect ratio.|
|height||Optional. The new height in pixels when action is resize. If unspecified or zero the new height is calculated from the width attribute, maintaining aspect ratio.|
If action is resize at least one of the width or height attributes must be specified.
The following example shows a scale operation. The file names need to be added to suit. The resulting file is streamed to the browser using <cfcontent> without deleting it. The jpeg quality is set to 80.
<cfx_jpegresize action="scale" factor="30"
<cfcontent type="image/jpeg" file="C:\path\to\image\file.jpg">
The next example shows a resize operation. The file names need to be added to suit. The new file will be 200 pixels wide and the aspect ratio will be maintained, because the new height is not specified. The resulting file is streamed to the browser using <cfcontent> and is automatically deleted. The Internet Guest User account must have "full control" of the directory containing the file for it to be deleted.
<cfx_jpegresize action="resize" width="200"
<cfcontent type="image/jpeg" file="C:\path\to\image\file.jpg"
The final example shows how to upload an image and scale it. In this case a temporary file name is generated and the file is deleted after streaming it back to the browser. A working application would need to save the file somewhere permanently.
This is the upload form:
<form method="post" action="test.cfm" enctype="multipart/form-data">
<input type="file" name="filesent"><input type="submit" value="Submit">
This is the Cold Fusion script that processes the form data:
<cfset tempfile=currentdir & tempname & ".jpg">
<cffile action="upload" filefield="filesent" destination=#tempfile#>
<cfx_jpegresize action="scale" factor="30" source=#tempfile# filename=#tempfile#>
<cfcontent type="image/jpeg" file=#tempfile# deletefile="yes">
The first line prevents the page from caching. The second line sets a variable that holds the name of the current directory. The next two lines build a temporary file name that will be unique by using the CreateUUID function. Finally it is scaled, streamed back to the browser and deleted.
csImageFile - Resize and edit JPG, BMP, GIF, PNG, PCX, PSD, TIF and WBMP images.
csDrawGraph - Draw pie charts, bar charts and line graphs from an asp script.
csASPGif - Create and edit animated GIFs.
csASPUpload - Upload files through a browser form.
csFileDownload - Control file downloads from an ASP script.
csASPZipFile - Create zip files and control binary file downloads.
csIniFile - Use Windows style inifiles in your ASP applications.
csXImage - ActiveX control to display, edit and scan JPG, PNG, BMP, PCX, PSD, TIF and WBMP images.
csXGraph - ActiveX control to display pie charts, bar charts and line graphs.
csXPostUpload - A control for uploading the contents of a folder to a server using HTTP.
csXMultiUpload - Select and upload multiple files and post to a server using HTTP.
csASPNetGraph - .NET component for drawing pie charts, bar charts and line graphs.
csNetUpload - ASP.NET component for saving HTTP uploads.
csNetDownload - ASP.NET class to control file downloads.
© Chestysoft, 2012.