Aspjpeg component thumbnails and watermarks

Source: Internet
Author: User

I. scaling down images

<%
Set JPEG = server. Createobject ("persits. jpeg") Call the component
Path = server. mappath ("Images") & "/clock.jpg" Path of the image to be processed
JPEG. Open Path
The height and width are 1/2 of the original image.
JPEG. width = jpeg. originalwidth/2
JPEG. Height = jpeg. originalheight/2
Save image
JPEG. Save server. mappath ("Images") & "/clock_small.jpg"
%>
View the processed image

Ii. Image Watermark

<%
Set JPEG = server. Createobject ("persits. jpeg ")
JPEG. Open Server. mappath ("images/dodge_viper.jpg ")
Start writing text
JPEG. Canvas. Font. Color = & 000000 & prime; red color
JPEG. Canvas. Font. Family = "Courier New" font
JPEG. Canvas. Font. Bold = true bold or not
JPEG. Canvas. Print 10, 10, "Copyright (c) XYZ, Inc ."
Print coordinates x print coordinates y print characters
The following is the border processing for the image
JPEG. Canvas. Pen. Color = & h000000 & prime; black color
JPEG. Canvas. Pen. width = 2 paint width
JPEG. Canvas. Brush. Solid = false whether to perform 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
%>

3. Security Code

The principle of security Ma is similar to watermarking. Many friends asked me to ask for specific code technologies. Here I will share it with you. I will not tell anyone else. Haha.
<%
Function for generating security codes: www.knowsky.com
Function make_randomize (max_len, w_n) max_len generation length. w_n: 0 may contain letters. 1: only 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
%>

Generate a picture of the security code. Of course, you need to prepare a background image in advance.

<% Random_num = make_randomize () generates a four-digit security code
Session ("random_num") = Why does random_num call the session? the security code without the session is meaningless. Haha

Set JPEG = server. Createobject ("persits. jpeg") Call the component
JPEG. Open Server. mappath ("Infos/random_pic/random_index.gif") Open the prepared Image
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 ("Infos/random_pic/random_index.bmp") Save
%>

Do it yourself. Haha.

Iv. Image Cutting

For a long time, people who do not know about aspjpeg think that they cannot use it for cutting.
In fact, there is such a method
Crop X1, Y1, X2, Y2
Returns the X coordinate in the upper left corner of the rectangular shape, and the Y coordinate in the lower right corner of the Y coordinate.
Here is a demonstration.
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, start to cut is actually to remove the lower part of more than 52 pixels
JPEG. Save server. mappath ("/temp_pic/small_1.gif") Save
How is it? It's easy.

5. Image Merging

We need to add the logoimage to the dodge_viper.jpg image.
In fact, the image merging method can also be used for dynamic watermarking.
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 the output method of sendbinary is used here. Of course, you can save and modify the dodge_viper.jpg file, and then enter it. I personally do not like to use the sendbinary method, which is prone to errors when the network speed is slow. The speed is not very good. Haha.

Vi. Database Support

I will not talk about it here. It is actually the binary method. We know that images can only be saved as binary files in the database. So the code is too lazy to write.

7. More Methods

Canvas. Line (left, top, right, bottom)
Draw a straight line
Canvas. ellipse (left, top, right, bottom)
Draw an elliptic
Canvas. Circle (X, Y, radius)
Draw a circle
Canvas. Bar (left, top, right, bottom)
Draw a rectangle with code on it.
Canvas. Font. shadowcolor
Text shadow color
Canvas. Font. shadowxoffset as long
Shadow X coordinate settings
Canvas. Font. shadowyoffset as long
Y coordinate settings
Canvas. Font. bkmode as string
Text background

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.