ASP program to upload the image add watermark effect!_ application skills

Source: Internet
Author: User
Tags save file trim
AspJpeg is a persits-produced shareware, the probationary period is 30 days, you can download here: Http://www.persits.com/aspjpeg.exe.
The latest version number is 1.3.
=========================================
<%
Sub Jpegclass (imgurl,fontsize,family,isbold,top,left,content,horflip) ' Invoke procedure name

Dim Jpeg,font_color,font_size,font_family,f_width,f_height,f_content,f_horflip
' 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
If Horflip = 1 Then
Jpeg.fliph
' Jpeg.sendbinary
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

Call Jpegclass ("Apple.jpg", 13, "italics", 1,18,18, "Hello, this is a watermark program", 1)
%>

Download AspJpeg build first, use after registration

############### #转载方法2 ####################

ASP to add watermark to the image is the need for components ... Commonly used with AspJpeg software and the Chinese developed their own wsimage software, you can search the Internet to download these two software, recommended the use of our own development of the Chinese wsimage, after all, is the Chinese version, easy to operate.

How to register a component:

At the command prompt, enter "regsvr32 [DLL path]".

Image add watermark is simply to get the picture size, and then write the watermark up. The ASP code is just a control component. Use code to explain everything.

One: Get the picture size (here is the pixel value). All the friends who are learning Photoshop should understand.

<%

Set Obj=server. CreateObject ("Wsimage.resize") ' Invoke component

Obj. Loadsoucepic Server.MapPath ("25.jpg") ' Open the picture, the picture name is 25.jpg

Obj. Getsourceinfo Iwidth,iheight

Response.Write "Picture width:" & iwidth & "<br>" "Get Picture width

Response.Write "Picture height:" & iheight & "<br>" ' Get picture height

Strerror=obj.errorinfo

If strerror<> "" Then

Response.Write Obj.errorinfo

End If

Obj.free

Set obj=nothing

%>

''----------------------------------------------------------------''

Two: Add text watermark

<%

Set Obj=server. CreateObject ("Wsimage.resize")

Obj. Loadsoucepic Server.MapPath ("25.jpg") ' Load picture

Obj. Quality=75

Obj. Txtmarkfont = "Chinese Cloud" ' Set watermark text font

Obj. Txtmarkbond = False ' sets the thickness of the watermark text

Obj. markrotate = 0 ' The rotation angle of the watermark text

Obj. Txtmarkheight = 25 ' height of watermark text

Obj. Addtxtmark Server.MapPath ("txtmark.jpg"), "take you out of the departure", &h00ff00& 10, 70

Strerror=obj.errorinfo ' produces the picture name, the text color is the watermark in the picture position

If strerror<> "" Then

Response.Write Obj.errorinfo

End If

Obj.free

Set obj=nothing

%>

''----------------------------------------------------------------''

Three: Add a picture watermark

<%

Set Obj=server. CreateObject ("Wsimage.resize")

Obj. Loadsoucepic Server.MapPath ("25.jpg") ' Load picture

Obj. Loadimgmarkpic Server.MapPath ("blend.bmp") ' Load watermark picture

Obj. Quality=75

Obj. Addimgmark Server.MapPath ("imgmark.jpg"), 315, 220,&AMP;HFFFFFF, 70

Strerror=obj.errorinfo ' produces the picture name, the text color is the watermark in the picture position

If strerror<> "" Then

Response.Write Obj.errorinfo

End If

Obj.free

Set obj=nothing

%>

''----------------------------------------------------------------''

In fact, add a watermark to the picture is so simple. And then I'm going to say another two main usages of the WsImage.dll component. Includes:

Trim the picture and generate a thumbnail of the picture.

Or in my habit, use code to add notes:

To trim a picture:

<%

Set Obj=server. CreateObject ("Wsimage.resize")

Obj. Loadsoucepic Server.MapPath ("25.jpg")

Obj. Quality=75

Obj.cropimage Server.MapPath ("25_crop.jpg"), 100,10,200,200 ' define cut size and generate picture name

Strerror=obj.errorinfo

If strerror<> "" Then

Response.Write Obj.errorinfo

End If

Obj.free

Set obj=nothing

%>

Detailed note: Cut the picture to use the Wsimage Cropimage method. When the definition generates the picture, 100,10 is the cut point in the upper left corner, which is 100 pixels to the left of the picture, and the top 10 pixels. The latter two 200 represent the cut of the broadband and high and height.

''----------------------------------------------------------------''

To generate a thumbnail image of a picture:

<%

Set Obj=server. CreateObject ("Wsimage.resize")

Obj. Loadsoucepic Server.MapPath ("25.jpg") ' Load picture

Obj. Quality=75

Obj. Outputspic Server.MapPath ("25_s.jpg"), 0.5,0.5,3 ' defines the name of the thumbnail as the size

Strerror=obj.errorinfo

If strerror<> "" Then

Response.Write Obj.errorinfo

End If

Obj.free

Set obj=nothing

%>

Detailed Description:

There are four ways to export a thumbnail:

(1) obj. Outputspic Server.MapPath ("25_s.jpg"), 200,150,0

200 for the output width, 150 for the output is high, this type of output is forced output width high, may cause picture distortion.

(2) obj. Outputspic Server.MapPath ("25_s.jpg"), 200,0,1

With 200 as the output width, the output height will scale with the column.

(3) obj. Outputspic Server.MapPath ("25_s.jpg"), 0,200,2

Output is high with 200, and the output width will scale with the column.

(4) obj. Outputspic Server.MapPath ("25_s.jpg"), 0.5,0.5,3

The first 0.5 indicates that the resulting thumbnail is half the width of the original image, which means a narrowing ratio.

The second 0.5 means that the resulting thumbnail is half the height of the original image, which means a high narrowing ratio.

A wide-height narrowing of the proportions means that the original image will be scaled down. If the zoom ratio is greater than 1, the original image is magnified.


I hope this technical article will help you.


Applet details and download address: http://www.mbsky.com/SoftView/SoftView_38956.html
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.