We want a thumbnail image for our boat picture. Normally we would have to use a component such as ImageGlue to derive a thumbnail every time the image was referenced. However if we create a thumbnail only once and save it as metadata we can dramatically reduce the load on the server.

 

   
Setup
 
     

First we set up the path to our image and then call our MakeThumbnail function to create a thumbnail for it. We're not detailing here how the MakeThumbnail function works but it would probably call a component such as ImageGlue to shrink the image down to appropriate dimensions before returning a JPEG image formatted as an array of bytes. This array of bytes is assigned to the variable 'theThumb'.

thePath = Server.MapPath("images/boat.jpg")
theThumb = MakeThumbnail(thePath)


   
Save
 
     

Then we save the thumbnail as an item of metadata. Here we've decided to call it 'preview' but you could use any name you wanted.

Set theFile = Server.CreateObject("MetaFiler2.File")
theFile.SetFile(thePath)
Set theData = theFile.Add("preview")
theData.Data = theThumb