AspJpeg is a very powerful image processing component, a pure English version. However, there has been a free version and cracked version, but the detailed and in-depth introduction of the article is not much, even if there is only a picture of the thumbnail and image watermark. Maybe it's because of pure English.
This is where I talk about the advanced usage of aspjpeg. The main technologies here include:
Thumbnail image
Picture watermark
Security Code Technology
Picture Cutting
Picture Merge
Database support
More less frequently Used method introduction
And some of the relevant practical techniques
AspJpeg the only point is that the output mode is relatively single. Here, we mainly talk about how to save the image processing and then call this output method. In addition, I am lazy, so some code is still quoted in the original file, do not understand the place I will explain!
The comrade who has studied VB or. NET must see it clearly. Brush again. Oh.
One, the picture is abbreviated
<%
Set Jpeg = Server.CreateObject ("Persits.jpeg") Invoke component
Path = Server.MapPath ("Images") & "\clock.jpg" Picture path to process
Jpeg.open Path Open Picture
High and wide for the original picture of 1/2
Jpeg.width = JPEG.ORIGINALWIDTH/2
Jpeg.height = JPEG.ORIGINALHEIGHT/2
Save picture
Jpeg.save Server.MapPath ("Images") & "\clock_small.jpg"
%>
View processed Pictures
Second, picture watermark
<%
Set Jpeg = Server.CreateObject ("Persits.jpeg")
Jpeg.open Server.MapPath ("Images/dodge_viper.jpg")
Start writing text
Jpeg.Canvas.Font.Color = &000000 ' red color
Jpeg.Canvas.Font.Family = "Courier New" font
Jpeg.Canvas.Font.Bold = True is bold
Jpeg.Canvas.Print, "Copyright (c) XYZ, Inc."
Print coordinates x print coordinates y the characters you need to print
The following is a border treatment of a picture
Jpeg.Canvas.Pen.Color = &h000000 ' Black color
Jpeg.Canvas.Pen.Width = 2 Brush width
Jpeg.Canvas.Brush.Solid = False is bold processing
Jpeg.Canvas.Bar 1, 1, jpeg.width, jpeg.height
Start x coordinate start y coordinate input length input height
Jpeg.save Server.MapPath ("images/dodge_viper_framed.jpg") Save
%>
Third, security code
Safe Ma Truth and add watermark almost, a lot of friends asked me to specific code technology, here I write to share with you, ordinary people I do not tell him. Oh.
<%
function www.knowsky.com to generate security code
function Make_randomize (max_len,w_n) Max_len build length, w_n:0 may contain letters, 1: Only for numbers
Randomize
For Intcounter=1 to Max_len
Whatnext=int ((1-0+1) *rnd+w_n)
If Whatnext=0 Then
upper=122
lower=97
Else
upper=57
lower=48
End If
Strnewpass=strnewpass & Chr (int ((upper-lower+1) *rnd) +lower)
Next
Make_randomize=strnewpass
End Function
%>
A picture that generates a security code. Of course, you have to prepare a background picture beforehand.
<%random_num=make_randomize (4,1) generates a 4-digit security Code
Session ("Random_num") =random_num why call session, no session of the security code is completely meaningless. Oh
Set Jpeg = Server.CreateObject ("Persits.jpeg") Invoke component
Jpeg.open Server.MapPath ("Infos/random_pic/random_index.gif") open the prepared picture
Jpeg.Canvas.Font.Color = &h006699
Jpeg.Canvas.Font.Family = "Arial Black"
Jpeg.Canvas.Font.Bold = False
Jpeg.Canvas.PrintText 0,-2, Random_num
Jpeg.save Server.MapPath ("Http://edu.cnzz.cn/NewsInfo/infos/random_pic/random_index.bmp") Save
%>
Do it yourself. Oh.
Four, picture cutting
For a long time, people who don't know aspjpeg think they can't use it for cutting.
In fact there is such a method of
Crop X1,y1,x2,y2
Cut rectangular type upper left corner x coordinate, y coordinate x coordinate y coordinate
I'm going to do a demo right now, huh?
Set Jpeg = Server.CreateObject ("Persits.jpeg")
Jpeg.open server. MapPath ("/pic/1.gif")
Jpeg.width=70
Jpeg.height = Jpeg.originalheight*70/jpeg. Originawidth
Jpeg.crop 0,0,70,52 Start Cutting is actually removing the lower part of more than 52 pixels.
Jpeg.save server. MapPath ("/temp_pic/small_1.gif") Save
Well, it's easy.
V. Picture merging
We're here to add the logo picture to the dodge_viper.jpg picture.
In fact, the image of the combination of methods can also be used to dynamic water printing OH
Set Photo = Server.CreateObject ("Persits.jpeg")
Photopath = Server.MapPath ("Images") & "\dodge_viper.jpg"
Photo.open Photopath
Set Logo = Server.CreateObject ("Persits.jpeg")
Logopath = Server.MapPath ("Images") & "\clock.jpg"
Logo.open Logopath
Logo.width = 70
Logo.height = Logo.width * logo.originalheight/logo.originalwidth
Photo.drawimage 0, 0, Logo
Photo.sendbinary uses the Sendbinary output method here. Of course, you can also save the changed dodge_viper.jpg first, and then enter it. I personally do not like using the Sendbinary method, when the speed is slow, error prone. Not so in terms of speed. Oh.
Vi. Database Support
There's not much to say here. In fact, is the binary method, we know that the image stored in the database can only be stored as binary files. So the code is lazy to write.
Vii. more ways of introducing
Canvas.line (left, top, right, Bottom)
Draw a straight line
Canvas.ellipse (left, top, right, Bottom)
Draw an Ellipse
Canvas.circle (X, Y, Radius)
Draw a Circle
Canvas.bar (left, top, right, Bottom)
Draw a rectangle with code that describes the
Canvas.Font.ShadowColor
Text Shadow Color
Canvas.Font.ShadowXOffset as Long
Shadow X coordinate set
Canvas.Font.ShadowYOffset as Long
Y-coordinate setting
Canvas.Font.BkMode as String
Text background
The author of this article: Rain waves
This department is reproduced, the copyright belongs to the original author all