Price: US$79.00

Pay securely at PayPal. On the confirmation page, click Continue to product download page to download this product immediately.

Having a PayPal account is optional; if you don't want to sign up, look for the link which says Don't have a PayPal account?

Ultimate Image Resizer

Classic ASP Sample

Although the Ultimate Image Resizer is a .NET component designed for use by .NET applications, it is COM-Visible and therefore it can be accessed from VB, including classic ASP using VBScript.

This page shows how the Ultimate Image Resizer can be used from classic ASP 3. Please note that in order to use the code, you need to purchase and download the Ultimate Image Resizer, and then register the downloaded DLL using regasm.exe.

Important note: you will only be able to use the Ultimate Image Resizer if your website is hosted on a server with the .NET 2 runtime installed, and you must be able to register COM components on the server. You can probably only do this if you have a dedicated server for your website or your company's websites. If you are unsure, please check with your network team or web hosting company before purchasing the Ultimate Image Resizer.

In the example, an image on the web server is loaded, and is resized to two different sizes and displayed. Image uploading is not including in this sample as other 3rd party components are normally required to achieve file uploading in classic ASP.

Registering DotNetHelpers.UltimateImageResizer.dll

The first step is to register the Ultimate Image Resizer DLL using regasm.exe which is a program used to register .NET assemblies as COM components. The regasm.exe program lives in the .NET framework directory, for example C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727. Go to the command prompt to the same folder which contains the Ultimate Image Resizer DLL and run the following command:

regasm /tlb /codebase DotNetHelpers.UltimateImageResizer.dll

Sample VBScript code

The following code loads an image of the disk and creates 2 resized copies of it.

<%
Option Explicit

' In this example, an image which exists on the server is resized to 2 sizes.

' Make sure this image exists before running. This is the source image which will be resized.
Dim pathToImage
pathToImage = "c:\temp\image.jpg"

' All resized images will be added to the following folder,
' which should exist before running this code.
Dim outputFolder
outputFolder = Server.MapPath("/Images")

' Declare the variables which will hold the URLs of the resized images
Dim largeImageUrl, smallImageUrl

' Create an instance of the image resizer
Dim resizer
Set resizer = CreateObject("DotNetHelpers.UltimateImageResizer.ImageResizer")

' The second overload of 'Load' takes a string
resizer.Load_2 pathToImage

' If the image is sideways, then rotate it
resizer.RotateIfNeeded

' Set the resize mode for the large image. The following settings are available:
' 0 = Stretch image; 1 = Keep original ratio; 2 = Keep ratio by padding; 3 = Keep ratio by cropping
resizer.Mode = 1

' Create the large version of the file
resizer.Resize_2 400, 400

' SaveToDisk has 2 parameters: OutputFormat and path
' For OutputFormat the following are available: 0 = JPG; 1 = GIF; 2 = PNG; 3 = BMP.
resizer.SaveToDisk 0, outputFolder & "\Large.jpg"
largeImageUrl = "/Images/Large.jpg"

' Now create a small version

' A different resize mode is used. The image will be cropped to fit into the size we specify.
resizer.Mode = 3
resizer.Resize_2 150, 150
resizer.SaveToDisk 0, outputFolder & "\Small.jpg"
smallImageUrl = "/Images/Small.jpg"

' Clean up the resizer
resizer.Dispose()
Set resizer = Nothing

%>

The HTML in the ASP page can then access the smallImageUrl and largeImageUrl variables to display the resized images:

<html>
    <body>
        <h1>Large Image</h1>
        <img src="<%= largeImageUrl %>" />
        
        <h1>Small Image</h1>
        <img src="<%= smallImageUrl %>" />
    </body>
</html>

Download sample

Download Download classic ASP Sample