Using JPEG component to add image watermark function

Source: Internet
Author: User
Tags exit save file
function to write the image watermark effect function, the code is as follows:

Program code:

Sub Jpegclass (imgurl,fontsize,family,isbold,top,left,content) ' Invoke procedure name

Dim jpeg,font_color,font_size,font_family,f_width,f_height,f_content
' Establish an instance
Set Jpeg = Server.CreateObject ("Persits.jpeg")

font_size=10
Font_family= "Song Body"
F_left= 5
F_top=5

If imgurl<> "" Then
Jpeg.open Server.MapPath (imgurl) ' Picture path and open it
Else
Response.Write "Picture Path not Found"
Exit Sub
End If

If fontsize<> "then font_size=fontsize" Font size
If family<> "then font_family=family" font
If top<> "" then f_left=left Watermark to the left of the picture
If left<> "" then F_top=top "watermark from top position of picture
If content= "then" watermark content
Response.Write "Watermark What content, Watermark is unsuccessful!" "
Exit Sub
Else
F_content=content
End If


' Add text watermark
Jpeg.Canvas.Font.Color = &hff0000 ' Red
Jpeg.Canvas.Font.Family = font_family
Jpeg.canvas.font.size= font_size
If Isbold=1 Then
Jpeg.Canvas.Font.Bold = True
End If
Jpeg.Canvas.Print F_left, F_top, f_content

' Save file
Jpeg.save Server.MapPath (Imgurl)

' Logout Object
Set Jpeg = Nothing
Response.Write "Watermark was successful, the picture added" &content& "
End Sub

Calls are as follows: Call Jpegclass ("Psg.jpg", 13, "italics", 1,18,18, "Hello, this is the Watermark program")

can easily realize the image watermark effect, of course your server must support ASPJPEG components!

Sub Jpegclass (imgurl,fontsize,family,isbold,top,left,content) ' Invoke procedure name

Dim jpeg,font_color,font_size,font_family,f_width,f_height,f_content
' Establish an instance
Set Jpeg = Server.CreateObject ("Persits.jpeg")

font_size=10
Font_family= "Song Body"
F_left= 5
F_top=5

If imgurl<> "" Then
Jpeg.open Server.MapPath (imgurl) ' Picture path and open it
Else
Response.Write "Picture Path not Found"
Exit Sub
End If

If fontsize<> "then font_size=fontsize" Font size
If family<> "then font_family=family" font
If top<> "" then f_left=left Watermark to the left of the picture
If left<> "" then F_top=top "watermark from top position of picture
If content= "then" watermark content
Response.Write "Watermark What content, Watermark is unsuccessful!" "
Exit Sub
Else
F_content=content
End If


' Add text watermark
Jpeg.Canvas.Font.Color = &hff0000 ' Red
Jpeg.Canvas.Font.Family = font_family
Jpeg.canvas.font.size= font_size
If Isbold=1 Then
Jpeg.Canvas.Font.Bold = True
End If
Jpeg.Canvas.Print F_left, F_top, f_content

' Save file
Jpeg.save Server.MapPath (Imgurl)

' Logout Object
Set Jpeg = Nothing
Response.Write "Watermark was successful, the picture added" &content& "
End Sub

Calls are as follows: Call Jpegclass ("Psg.jpg", 13, "italics", 1,18,18, "Hello, this is the Watermark program")

can easily realize the image watermark effect, of course your server must support ASPJPEG components!

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.