ASPThumb User's Manual

About ASPThumb

ASPThumb is an ASP component that allows ASP application to create high-quality thumbnails. You can use this component for automated creation of image previews in your ASP applications. The component can resize and crop images, draw image border, etc. The resulting thumbnail can be saved to file or binary variable as JPEG image. The component can load the JPEG, GIF, PNG, BMP and TIFF images from files or binary variables.

To go to the ASPThumb home page, please click here.

How to install the trial version

Follow the steps below to install the trial version of component on your server:

  1. unzip aspthumb_trial.zip to any folder on the server;
  2. register component there using the regsvr32 command-line system utility as follows:

    regsvr32 aspthumb32_trial.dll
    (on 32-bit versions of Windows)

    regsvr32 aspthumb64_trial.dll
    (on 64-bit versions of Windows)

    On Windows Vista or Windows 7, you should run Command Prompt utility "as Administrator" (from popup menu), and then run regsvr32 command. Otherwise regsvr32 can be unable to modify system registry to register the component.

Note: the trial version places a trial message on created thumbnails.

Purchase

The trial version is intended for evaluation purposes only.
You can order the full version of ASPThumb on our site.

How to install the full version

Follow the steps below to install the full version of component on your server:

  1. unzip aspthumb.dll (from the full version package) to any folder on the server;
  2. register component there using the regsvr32 command-line system utility as follows:

    regsvr32 aspthumb32.dll
    (on 32-bit versions of Windows)

    regsvr32 aspthumb64.dll
    (on 64-bit versions of Windows)

    On Windows Vista or Windows 7, you should run Command Prompt utility "as Administrator" (from popup menu), and then run regsvr32 command.

  3. restart IIS service;
  4. remove trial version (aspthumb_trial.dll) from the server.

How to use

To create a thumbnail of an image using ASPThumb, follow these simple steps:

  1. Create an instance of the ASPThumb object.
  2. Load an image file via the Load method or assign the image data to BinaryData property.
  3. Resize image via the Resize method.
  4. Save the resulting thumbnail to disk via the Save method, or send it directly to client browser via the Send method, or assign it to binary variable via the BinaryData property.

Below you can see a few examples of thumbnail creation using ASPThumb.

Load the image from disk, create the thumbnail and save it to disk:

<%
set tn = server.createObject("briz.AspThumb")
tn.Load "c:\temp\photo.jpg"
tn.Resize 100, 100
tn.EncodingQuality = 80
tn.Save "c:\images\thumbnail.jpg"
%>

Load the image from disk, create the thumbnail and send it to client browser:

<%
set tn = server.createObject("briz.AspThumb")
tn.Load "c:\temp\photo.jpg"
tn.Resize 100, 100
tn.EncodingQuality = 80
tn.Send
%>

Load the image from disk, create the thumbnail and save it to database:

<%
set tn = server.createObject("briz.AspThumb")
tn.Load "c:\temp\photo.jpg"
tn.Resize 100, 100
tn.EncodingQuality = 80

'Connect to Access database and open the "photos" table
strConnect = "DRIVER={Microsoft Access Driver (*.mdb)};DBQ=" & "c:\data\photos.mdb"
Set rs = Server.CreateObject("adodb.recordset")
rs.Open "photos", strConnect, 1, 3 

'Append the row to table
rs.AddNew

'Assign the thumbnail data to table field
rs("thumbnail").Value = tn.BinaryData

rs.Update
rs.Close
Set rs = Nothing
%>

Load the image from database, create the thumbnail and send it to client browser:

<%
strConnect = "DRIVER={Microsoft Access Driver (*.mdb)};DBQ=" & "c:\data\photos.mdb"
set conn = server.createObject("ADODB.Connection")
conn.Open strConnect

Set rs = Server.CreateObject("adodb.recordset")
rs.Open "select * from photos where id = 2", conn

set tn = server.createObject("briz.AspThumb")

'Assign the image data to ASPThumb
tn.BinaryData = rs("original_image").Value

tn.Resize 100, 100
tn.EncodingQuality = 80
tn.Send

rs.Close
Set rs = Nothing
%>

Object Reference

Methods

Sub Load(FileName As String)

Loads a image file.

Sub Save(FileName As String)

Encodes the loaded image to JPEG and saves the result to the specified file.

Sub Send()

Encodes the loaded image to JPEG and sends the result directly to the client browser by internally calling the Response.BinaryWrite method. Automatically sets the Content-Type header to "image/jpeg".

Sub Close()

Closes the loaded image and frees the resources. This method is called automatically when the asp script execution is finished.

Sub Resize(MaxWidth As Long, MaxHeight As Long, Crop As Boolean)

Reduces the loaded image to MaxWidth and MaxHeight maintaining its aspect ratio. To choose the resizing algorithm use the ResizeQuality property.

If the Crop parameter is True, the image will be croped before resizing. The result size of image will be MaxWidth x MaxHeight exactly. The Crop parameter is optional. By default is False.

Sub Crop(Left As Long, Top As Long, Width As Long, Height As Long)

Crops the loaded image.

Sub DrawFrame(Width As Byte, Color As OleColor)

Draws the frame around the loaded image. The Width parameter specifies the frame width in pixels. The Color parameter specifies the frame color. For example:
tn.DrawFrame 2, vbGray
tn.DrawFrame 1, &h405060&
40 - blue color component. Two hexadecimal digits (from 00 to FF).
50 - green color component. Two hexadecimal digits (from 00 to FF).
60 - red color component. Two hexadecimal digits (from 00 to FF).

Sub DrawText(X As Long, Y As Long, Text As String)

Draws a text string on the loaded image. The X and Y parameters specify the position for drawing the text.

Sub SetFont(FontName As String, FontSize As Long, Bold As Boolean, Italic As Boolean, Underline As Boolean, Color As OleColor)

Sets the font parameters for the DrawText method. For example:
tn.SetFont "Arial", 18, True, False, False, vbWhite

Sub SetBackgroundColor(Color As OleColor)

Sets the background color for transparent images (GIF, PNG). For example:
tn.SetBackgroundColor vbWhite

Properties

Property BinaryData As Variant (read/write)

Represents the binary data that contains the current image.

Property Width As Long (read-only)

Specifies the current image width.

Property Height As Long (read-only)

Specifies the current image height.

Property ResizeQuality As Byte (read/write)

Specifies the resizing quality. Valid values for this property are:
  • 0 - the image will be resized using the fast algorithm without smoothing.
  • 1 - the image will be resized using the Bilinear algorithm that provides rather high quality and is much faster then Lanczos3. This value is set by default.
  • 2 - the image will be resized using the Lanczos3 algorithm that provides the best quality for photos.
For this property to take effect, you must set it before calling Resize.

Property EncodingQuality As Byte (read/write)

Specifies the JPEG encoding quality. Valid values are 1-100. This property is set to 80 by default.

Property ProgressiveEncoding As Boolean (read/write)

Specifies whether an image can be progressively displayed when it is decompressed. ProgressiveEncoding is true by default.


Copyright © 2011 BRIZ Software