Description of "showthumb.asp"

This script is short but important. It is called for each thumbnail image and it receives a QueryString variable called "JpegName" which tells it which image to display.

<%
Response.Expires = 0
Response.Buffer = true
Response.Clear

Set Image = Server.CreateObject("csImageFile.Manage")

Image.ReadFile Server.MapPath("images/" & Request.QueryString("JpegName") &_
  ".jpg")
Image.Scale 15

Response.ContentType = "image/jpeg"
Response.BinaryWrite Image.JPGData
%>

The first 3 lines prevent the page from caching. This is recommended when creating images using ASP.

Then we create an instance of the csImageFile object. If you are using the trial component you must replace "csImageFile" with "csImageFileTrial".

Next we read the image into csImageFile. The parameter is the physical path and file name of the full size jpg image. We use Server.MapPath to find the physical path. The images are in a sub directory called "Images". The file name is the name provided in the URL variable with ".jpg" appended. You can hard code the full path if you know it.

Then we resize the image. This is a scaling to 15% of the original size.

Finally, we stream the image to the browser in JPG format. It is important to set the content type. Internet Explorer will display the JPG correctly without it but other browsers, including Netscape, can have problems.

Creating thumbnails in this way is a very common way to use csImageFile and there are a lot of variations of how it can be done. This example is relatively simple with only 4 images, all in the same directory, and the file names are hard coded into the <img> tags. It would be possible to list files from a directory and restrict the number on each page. It would also be possible to do something to each image, such as adding some text like a copyright notice.