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 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 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.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 ReferenceMethodsSub 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 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 © 2011 BRIZ Software
|