General image/Text watermark Functions

Source: Internet
Author: User
<%
Call CreateView ("UploadFile/f.jpg", "1 ")
'Createview (source image path, text/image watermark)
'----------------------------------
'Create preview image and watermark: call CreateView (file path, watermark image file to be added)
'Design by Seven (See7di@Gmail.com) (www.7di.net)
Sub CreateView (imagename, inttype)
Dim Object, objFont, img, Obj, LogoPath, sWidth, sHeight
Img = "/a.jpg" '// LOGO File
SWidth = "147" '// LOGO width
SHeight = "52" '// LOGO height
LogoPath = Server. MapPath (img) '// LOGO path
Set Obj = Server. CreateObject ("Persits. Jpeg") '// create a LOGO object
Set Object = Server. CreateObject ("Persits. Jpeg") '// create the source image Object
On Error resume Next
Obj. Open LogoPath '// read the LOGO
If err> 0 Then
Response. Write ("sorry, failed to get the LOGO image file! ")
Response. End ()
End if
Object. Open Trim (Server. MapPath (imagename) '// read the source Image
If err> 0 Then
Response. Write ("sorry, failed to get the image file to be processed! ")
Response. End ()
End if
Obj. Width = sWidth '// Add the original image Width
Obj. Height = sHeight '// Add the original image Height
 
'\ If the source image is larger than the LOGO
If Object. width> Cint (Obj. Width) and Object. Height> Cint (Obj. Height) Then
StrDo = "yes"
End if
If inttype = 1 Then
Object. Canvas. Font. Color = & HFF0000 '// text Color
Object. Canvas. Font. Family = "Verdana" '// text Font
Object. Canvas. Font. Bold = true' // whether to Bold
Object. Canvas. Print 10, 10, "www.Sditi.com" '// Print the coordinates x Print the characters that y needs to Print
Object. Canvas. Pen. Color = & h000000' // background Color
Object. Canvas. Pen. Width = 1' // paint Width
Object. Canvas. Brush. Solid = false' // whether to perform rough Processing
Object. Canvas. Bar 0, 0, Object. Width, Object. Height '// start X coordinate start Y coordinate input length input Height
Else
If strDo = "yes" Then
Object. Canvas. Pen. Color = & hffffff' // border Color
Object. Canvas. Pen. Width = 0' // Border Width
Object. Canvas. Brush. Solid = false' // specifies whether the color is filled in the border of the image.
Object. DrawImage Object. Width/2, Object. Height/2, Obj, 0.7, & HFFFFFF, 90' // Add the position, coordinates, and transparency of the image (add a watermark image)
Object. Canvas. Bar 0, 0, Object. Width, Object. height' // coordinates of the position of the border line of the image
Object. Width = Object. Width
Object. height = Object. height
Object. Sharpen 1,120
End if
End If
Object. Save Server. MapPath (imagename) '// generate a file
Set Obj = Nothing
End Sub
%>
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.