Add Comment
Using CFIMAGE to Generate Thumbnails Tutorial
ColdFusion Tutorial #19
Here is a tutorial I created using the new CFIMAGE tag in Coldfusion 8 to create thumbnails.
demo.cfm
Firstly you need to get the information on the "full size" image that we want to create the thumbnail for. To do this use the info action of cfimage as shown on line 1.Now that we have the information about the image, specifically the width and height we can begin the process of resizing. In this example the width of your thumbnail would never exceed 150 pixels and the height would not exceed 113 depend if the shot is horizontal or vertical. Of course you could adjust the 150 and 113 to suit your needs. We are doing this on lines 2-4.
Finally on Line 5 we resize the thumbnail using the resize action of cfimage. We are using the width and height variables we just calculated. This also writes the thumbnail image back out to the current directory. The thumbnail will be replaced every time for this demo to work.
Lines 7-9 simply display the original and resulting thumbnail image.
Demo
See this code running!
Download
Download this code as a zip!
Comments
Ah, very good.This can be used to automate creating the navigation images for pages.
Thanks!
Phillip Senn @ Tuesday 27 Nov 2007 - 01:10:50 AM
Click button to add a comment
Author
Damon Ledet
Published
Monday 19 Nov 2007Original
This tutorial has been modified and published with permission of the author. The original tutorial can be found herehttp://blog.damonledet.com/index.cfm/2007/11/18/Using-cfimage-to-create-thumbnails