Advanced usage for ASP JPEG image processing

Source: Internet
Author: User
Tags version
The advanced AspJpeg is a very powerful picture processing component, the 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:

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 = &hff0000 ' 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

Security code and add watermark is similar, many friends asked me to specific code technology, here I write to share with you, the General people I do not tell him. Oh.
<%
A function that generates a 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://www.webjx.com/htmldata/2005-12-09/infos/random_pic/random_index.bmp") Save
%>
Do it yourself. Oh.
Don't want to do the background picture. Go to random_index.gif and download it.

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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.