November 7, 2014 07:11 by
Peter
AspJpeg may be a server part which will facilitate your Classic ASP or ASP.NET applications with all their image-management desires. With AspJpeg, you'll be able to produce high-quality thumbnails, logo-stamp pictures, extract metadata information from pictures, crop, enhance, rotate, convert, more a lot of. Now, I am going to show you how to Create a thumbnail image sample with ASPJpeg in Classic ASP:
<%
' Create instance of AspJpeg
Set Jpeg = Server.CreateObject("Persits.Jpeg")
' Open source image
Jpeg.Open "c:\yourabsolutepath\yourimage.jpg"
' New width
L = 100
' Resize, preserve aspect ratio
Jpeg.Width = L
Jpeg.Height = Jpeg.OriginalHeight * L / Jpeg.OriginalWidth
' create thumbnail and save it to disk
Jpeg.Save "c:\yourabsolutepath\yourthumbnail.jpg"
%>
And now, we are goint to Resize with ASPJpeg. The following script will open a JPEG image on the drive, resizes it and saves the resultant thumbnail back to disk.
<%
' 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"
%>
Send your Thumbnail Directly to Browser
AspJpeg can send your thumbnail directly to the client browser rather than save it to disk. An image resizing script can be invoked via the SRC attribute of an <IMG> tag as below:
<IMG SRC="resize.asp?path=c:\dir\myimage.jpg&width=100">
Code for resize.asp as following:
<%
' 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
%>
Best and Cheap Classic ASP Hosting With AspEncrypt Recommendation
HostforLIFE.eu was founded in 2008. It has been topping the list of almost all the web hosting review sites so far. Still have websites running on ASP 3.0 or Classic ASP? Don’t worry; we still support legacy technology like Classic ASP Hosting. You can also mix and match Classic ASP and ASP.NET code in one single web site. We will make sure that Classic ASP runs smoothly on our servers and that your website is safer, faster and better supported than anywhere else! Our best and cheap Classic ASP hosting plan is starting at $5.00/mo. HostforLIFE.eu is now providing free domain and double SQL server space for new clients to enjoy the company’s outstanding web hosting service.