ASPJpeg by Persits
If you need to resize images on the fly, consider AspJpeg. This easy-to-use component enables you to create high-quality image thumbnails in just a few lines of code.Code Sample 1: Simple Resizing
The following script opens a JPEG image on the hard drive, resizes it and saves the resultant thumbnail back to disk.<head>
<title>Simple Resizing</title>
</head>
<body>
<blockquote>
<h2 align=center>Simple Resizing for ASPJPeg Script</h2>
<%
' Create an instance of AspJpeg
Set Jpeg = Server.CreateObject("Persits.Jpeg")
' Compute path to source
image
Path = Server.MapPath("images")
& "\test.jpg"
' Open source image
Jpeg.Open Path
' Decrease image size by
50%
Jpeg.Width = Jpeg.OriginalWidth
/ 2
Jpeg.Height = Jpeg.OriginalHeight
/ 2
' Optional: apply sharpening
Jpeg.Sharpen 1, 150
' Create thumbnail and
save it to disk
Jpeg.Save Server.MapPath("images")
& "\test_small.jpg"
%>
</blockquote>
</body>
</html>
Code Sample 2: Sending a Thumbnail Directly to Browser
AspJpeg is capable of sending a thumbnail directly to the client browser rather than saving it to disk. An image resizing script can be invoked via the SRC attribute of an <IMG> tag as follows:<IMG SRC="resize.asp?path=c:\dir\myimage.jpg&width=100">
<head>
<title>Sending a Thumbnail Directly to Browser</title>
</head>
<body>
<blockquote>
<h2 align=center>Sending a Thumbnail Directly to Browser</h2>
<%
' IMPORTANT: This script must not contain any HTML tags
' Create an instance of AspJpeg object
Set jpeg = Server.CreateObject("Persits.Jpeg")
jpeg.Open( Request("path") )
' Set new width
jpeg.Width = Request("width")
' Set new height, preserve
original width/height ratio
jpeg.Height = _
jpeg.OriginalHeight * jpeg.Width
/ jpeg.OriginalWidth
' Send thumbnail data to
client browser
jpeg.SendBinary
%>
</blockquote>
</body>
</html>
More: There is no technical information for this component. Component supplied by www.persits.com.
