ASPThumb User's Manual |
About ASPThumbASPThumb 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 scale down 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 BMP and JPEG images from files or binary variables. To go to the ASPThumb home page, please click here. How to install the trial versionFollow the steps below to install the trial version of component on your server:
Note: the trial version places a trial message on created thumbnails. Purchase
The trial version is intended for evaluation purposes only. How to install the full versionFollow the steps below to install the full version of component on your server:
How to useTo create a thumbnail of an image using ASPThumb, follow these simple steps:
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.ResizeQuality = 1
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.ResizeQuality = 1
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.ResizeQuality = 1
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.ResizeQuality = 1
tn.Resize 100, 100
tn.EncodingQuality = 80
tn.Send
rs.Close
Set rs = Nothing
%>
Object ReferenceMethodsSub Load(FileName As String)
Loads a JPEG or BMP image from file.
Sub Save(FileName As String)
Encodes a loaded image to JPEG and saves the result to file.
Sub Send()
Encodes a loaded image to JPEG and sends the result directly to 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)
Reduces the loaded image to MaxWidth and MaxHeight maintaining its aspect ratio.
To choose the resizing algorithm use the ResizeQuality property.
Sub Crop(WidthRatio As Long, HeightRatio As Long)
Crops the loaded image to set its aspect ratio to WidthRatio : HeightRatio.
For example if you want to create a thumbnail with 100x100 size, you can use the following code:
tn.Crop(100, 100) tn.Resize(100, 100) Sub DrawFrame(Width As Byte, Color As OleColor)
Draws the frame around the loaded image.
The Width parameter specifies the frame width in pixels, this parameter is optional and
by default is set to 1.
The Color parameter specifies the frame color, this parameter is optional and by
default is set to vbBlack.
For example:
tn.DrawFrame 'Draws the frame with width 1 pixel and black color. tn.DrawFrame 2, vbGray tn.DrawFrame 1, &h00505050 PropertiesProperty 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:
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 © 2001-2003 BRIZ Software
|