ASPJPEG is a shared software developed by Persits. The trial period is 30 days. You can download it at http://www.persits.com/asp;.exe.
The latest version is 1.3.
========================================================== =
<%
Sub program class (imgurl, fontsize, family, isbold, top, left, content, Horflip) 'call process name
Dim Jpeg, font_color, font_size, font_family, f_width, f_height, f_content, f_Horflip
'Create an instance
Set Jpeg = Server. CreateObject ("Persits. Jpeg ")
Font_size = 10
Font_family = ""
F_left = 5
F_top = 5
If imgurl <> "then
Jpeg. Open Server. MapPath (imgurl) 'image path and Open it
Else
Response. write "image 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 ', the watermark is left away from the image.
If left <> "" then f_top = top 'watermark off the top position of the image
If content = "" then' watermark content
Response. write "what is the watermark? The watermark fails! "
Exit sub
Else
F_content = content
End if
'Add a 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 the file
Jpeg. Save Server. MapPath (imgurl)
'Logout object
Set Jpeg = Nothing
Response. write "watermark succeeded." & content & "" is added to the image &""
End sub
Call watermark class ("apple.jpg", 13, "", 18, "Hello, this is the watermark program", 1)
%>
Download the aspjpeg component and use it after registration.
############### Reprint method 2 ####################
Adding watermarks to Images Using ASP requires components... common applications include aspjpeg software and wsImage software developed by the Chinese people. You can search and download the two software online. We recommend that you use the wsImage developed by the Chinese people. After all, it is a Chinese version and easy to operate.
Method for registering a component:
Enter "regsvr32 [Dll path]" at the command prompt.
Adding a watermark to an image is nothing more than obtaining the image size, and then writing the watermark. ASP code is just a control component. Use code to describe everything.
I. Obtain the image size (represented in pixels here. All the friends who learn PhotoShop should understand)
<%
Set obj = server. CreateObject ("wsImage. Resize") ''call the component
Obj. LoadSoucePic server. mappath ("25.jpg") ''open the image. The image name is 25.jpg.
Obj. GetSourceInfo iWidth, iHeight
Response. write "Image Width:" & iWidth & "<br>" ''To get the Image Width
Response. write "Image Height:" & iHeight & "<br>" ''To get the Image Height
StrError = obj. errorinfo
If strError <> "" then
Response. write obj. errorinfo
End if
Obj. free
Set obj = nothing
%>
''----------------------------------------------------------------''
Ii. Add a text watermark
<%
Set obj = server. CreateObject ("wsImage. Resize ")
Obj. LoadSoucePic server. mappath ("25.jpg")''
Obj. Quality = 75
Obj. TxtMarkFont = "文" ''sets the watermark text font
Obj. TxtMarkBond = false'' sets the watermark text width.
Obj. MarkRotate = 0'' watermark text Rotation Angle
Obj. TxtMarkHeight = 25'' height of the watermark text
Obj. AddTxtMark server. mappath ("txtMark.jpg"), "Take you away", & H00FF00 &, 10, 70
StrError = obj. errorinfo '': generate the image name. The text color is the position of the watermark in the image.
If strError <> "" then
Response. write obj. errorinfo
End if
Obj. free
Set obj = nothing
%>
''----------------------------------------------------------------''
3. Add an image watermark
<%
Set obj = server. CreateObject ("wsImage. Resize ")
Obj. LoadSoucePic server. mappath ("25.jpg")''
Obj. LoadImgMarkPic server. mappath ("blend.bmp") ''loads the watermark image
Obj. Quality = 75
Obj. AddImgMark server. mappath ("imgMark.jpg"), 315,220, & hFFFFFF, 70
StrError = obj. errorinfo '': generate the image name. The text color is the position of the watermark in the image.
If strError <> "" then
Response. write obj. errorinfo
End if
Obj. free
Set obj = nothing
%>
''----------------------------------------------------------------''
In fact, adding a watermark to an image is that simple. Then I will explain the other two main usage of the WsImage. dll component, including:
Crop an image to generate a thumbnail.
I still get used to it and add comments with the code to describe:
Crop images:
<%
Set obj = server. CreateObject ("wsImage. Resize ")
Obj. LoadSoucePic server. mappath ("25.jpg ")
Obj. Quality = 75
Obj. cropImage server. mappath ("25_crop.jpg"), 200,200, 10, ''defines the cut size and the name of the generated image
StrError = obj. errorinfo
If strError <> "" then
Response. write obj. errorinfo
End if
Obj. free
Set obj = nothing
%>
Note: The CropImage method of WsImage is used for image cropping. when an image is generated, 100 and 10 are the cut points in the upper left corner, that is, pixels on the left and 10 pixels on the top. the last two 200 represents the cut bandwidth and height.
''----------------------------------------------------------------''
Generate image thumbnails:
<%
Set obj = server. CreateObject ("wsImage. Resize ")
Obj. LoadSoucePic server. mappath ("25.jpg")'' load the image
Obj. Quality = 75
Obj. OutputSpic server. mappath ("25_s.jpg"), 0.5, 0.5, 3 ''defines the size of the thumbnail.
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 is the output width and 150 is the output height. This output form is forced output width and height, which may cause image deformation.
(2) obj. OutputSpic server. mappath ("25_s.jpg"), 200,0, 1
The output width is 200, and the output height scales with the ratio column.
(3) obj. OutputSpic server. mappath ("25_s.jpg"), 0,200, 2
The output height is 200, and the output width scales with the ratio column.
(4) obj. OutputSpic server. mappath ("25_s.jpg"), 0.5, 0.5, 3
The first 0.5 indicates that the generated thumbnail is half the width of the source image, that is, the width reduction ratio.
The second 0.5 indicates that the generated thumbnail is half the height of the source image, that is, the scaled down ratio is high.
The scaled-down ratio of the width and height is the same, which means that the ratio of the source image is reduced. If the zoom ratio is greater than 1, the source image is enlarged.
I hope this technical article will help you.
Applet details and: http://www.mbsky.com/SoftView/SoftView_38956.html