Usually when we make the website, the product picture, or the news picture and so on the display picture and so on will encounter because of the picture display position different size different problem. Some friends may have said that I can use the IMG tag's width and Height properties! You can use CSS to limit! Yes, yes, but have we noticed a problem that when you upload a picture of a small size, you want to display in a large position, the picture will pull very much. Similarly, you upload the picture size is very large, and the location is very small, the picture not only spent, and download speed will be very slow.
The general practice is to upload the use of AspJpeg components automatically cut out the need for several sizes, and then save separately. Of course, I have also seen the request to upload large maps, small map of the low-level approach. The disadvantage of this is obvious, if the site revision, the need to change the size of the picture will be cut once again. Also, when you edit a picture, you replace multiple dimensions at the same time.
Below, I will explain my experience in detail, Welcome to Exchange!
My method can achieve the following effects:
1, the size of the random, the picture will not be forced to shrink or enlarge the difficult to see;
2, can add watermark, and can be modified at any time;
3, can be anti-theft chain.
Principle is, the use of urlrewrite, the image link to the ASP processing, in the ASP file to use AspJpeg components, real-time processing picture size, and can perform real-time watermark and other tasks.
In the case of linking the picture, the SRC attribute of the IMG tag uses such an address, such as: Http://www.azhi.net.cn/photo/T16qFXXddnOtz1upjX_80_80.jpg, and then the Urlrewrite technology , convert this address to http://www.azhi.net.cn/picture.asp?p=T16qFXXddnOtz1upjX.jpg&w=80&h=80. The specific code for the picture.asp file is as follows:
copy content to clipboard
Code:
<%
Dim ojpeg, Swidth, Sheight, SPOSW, Sposh, spath
spath = Request.QueryString ("P")
Swidth = Request.QueryString ("W")
Sheight = Request.QueryString ("h")
Set ojpeg = Server.CreateObject ("persits.jpeg") ' Create AspJpeg to image
Ojpeg.open Server.MapPath ("/photo/" & spath) ' Read the file
If swidth <> "" Then ojpeg.width = Swidth ' Sets the size of the picture to the required size
If sheight <> "" Then ojpeg.height = sheight
'---watermark operation started---
OJpeg.Canvas.Font.Color = &hffffff ' Color of the watermark Word
OJpeg.Canvas.Font.Size = 12 ' size of watermark Word
oJpeg.Canvas.Font.Family = "Arial" ' Font of watermark words
OJpeg.Canvas.Font.Bold = True ' watermark Word Bold
SPOSW = Ojpeg.originalwidth ' computes the position coordinate of the watermark Word
If swidth <> "" Then SPOSW = swidth
Sposh = Ojpeg.originalheight
If sheight <> "" Then Sposh = sheight
OJpeg.Canvas.Print sPosW-58, sPosH-18, "azhi.net.cn" ' writing Up
oJpeg.Canvas.Font.Family = "Song Body"
OJpeg.Canvas.Print sPosW-46, sPosH-28, "Azi's Blog"
'---watermark operation ended---
Ojpeg.sendbinary ' output after processing of the picture
Set Ojpeg = Nothing
%>