AspJpeg 1.6 Programmer's Manual
System Requirements
Windows 95/98/NT/2000 and
IIS 4.0+ and ASP or
Visual Basic 5.0+ or
Visual C++ 5.0+ or
any development environment supporting COM.
Your First Thumbnail
To create a thumbnail of a JPEG image using AspJpeg, you should take the following simple steps:
- Create an instance of the AspJpeg object via Server.CreateObject (or New if used in VB).
- Open your image file via the Jpeg.Open method.
- Set new image dimensions via the properties Jpeg.Width and Jpeg.Height. You may use read-only properties Jpeg.OriginalWidth and Jpeg.OriginalHeight to preserve the original width/height ratio.
- Optional: You may include calls to any or all of the following methods: Jpeg.Sharpen to apply sharpening to the resultant thumbnail, Jpeg.Crop to crop it, Jpeg.FlipV and Jpeg.FlipH to flip an image vertically and/or horizontally.
- Save the resultant thumbnail to disk via the Jpeg.Save method, or send it directly to the browser via the Jpeg.SendBinary method.
Here is the underlying ASP script:
<% ' Create instance of AspJpeg
Set Jpeg = Server.CreateObject("Persits.Jpeg")
' Compute path to source image
Path = Server.MapPath("images") & "\clock.jpg"
' Open source image
Jpeg.Open Path
' Decrease image size by 50%
Jpeg.Width = Jpeg.OriginalWidth / 2
Jpeg.Height = Jpeg.OriginalHeight / 2
' Apply sharpening if necessary
' Jpeg.Sharpen 1, 130
' create thumbnail and save it to disk
Jpeg.Save Server.MapPath("images") & "\clock_small.jpg"
%>
<IMG SRC="images/clock.jpg"><P>
<IMG SRC="images/clock_small.jpg">
注意:它是在你的默认站点上建立虚拟目录的,所以默认站点最好不要用,如果你的系统是NTFS的就要注意了,在相应的目录下,要修改添加文件时有权限,不然的话,无法正常工作。祝你好运。