Demo of creating thumbnails dynamically with ASP and ASPPhotoResizer

This is a downloadable demo showing how to use the ASPPhotoResizer component to display thumbnail images made from existing JPG files that are on the server. The ASPPhotoResizer component must be registered on the server before this demo can be run. This component and the demo files can be downloaded using the links below.

Download the demo - thumbnails.zip (2 KB)

Download the ASPPhotoResizer trial (2.5 MB)

The demo, thumbnails.zip, contains the following files. The component is not included with the demo files.

File Description
webpage.asp This is the page that is to be displayed in the browser. The thumbnail script is called up from IMG tags inside this page. This script must be edited before use to include paths to 4 existing JPG images.
streamimage.asp This is the script that calls the ASPPhotoResizer component. It loads each image, resizes it and streams it to the browser as a binary data stream. The original image on disk is unchanged.
readme.txt A description of the application, including some troubleshooting tips.

Some of the important features are explained below.

webpage.asp

This page contains 4 IMG tags arranged in a table. Instead of containing the address of a JPG file, each IMG tag uses "streamimage.asp" as the SRC attribute. The file name of each JPG to be displayed is passed as a querystring parameter in the SRC attribute. The 4 image variables must be filled in before this script will work, for example:

Image1 = "c:\images\1.jpg"

This file name is used in the IMG tag.

<img src="streamimage.asp?name=<%= Server.URLEncode(Image1) %>">

streamimage.asp

This script reads the querystring to find the path of the image to display. It creates an instance of the ASPPhotoResizer component, loads the image, resizes it and streams it to the browser. This code shows the 64 bit trial version of the component.

Set JPG = Server.CreateObject("ASPPhotoResizer64Trial.Resize")
Width = 200
Height = 150
JPG.LoadFromFile Request.QueryString("name")
JPG.ResizeBox Width, Height
JPG.StreamImage

ResizeBox resizes the image to make it fit into a box 200 x 150 pixels in size, maintaining the aspect ratio. StreamImage exports the new image as a binary data stream in JPEG format using the ASP BinaryWrite function. This command also sets the expiry date on the file to zero to prevent caching and sets the Content Type to "image/jpeg". No other output should be included in this script.

Other Examples