通用 图片/文字 水印函数
生活随笔
收集整理的這篇文章主要介紹了
通用 图片/文字 水印函数
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
<%
Call CreateView("UploadFile/f.jpg","1")
'CreateView(原圖路徑,文字/圖象水印) '----------------------------------
'創建預覽圖片及打水印:call CreateView(文件的路徑,要添加的水印圖片文件)
'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文件
sWidth = "147"'//LOGO的寬
sHeight = "52"'//LOGO的高 LogoPath = Server.MapPath(img)'//LOGO路徑
Set Obj = Server.CreateObject("Persits.Jpeg")'//建立LOGO對象
Set Object = Server.CreateObject("Persits.Jpeg")'//建立原圖對象
On Error resume Next
Obj.Open LogoPath'//讀取LOGO
If err>0 Then
Response.Write ("對不起,獲取LOGO圖片文件失敗!")
Response.End()
End if
Object.Open Trim(Server.MapPath(imagename))'//讀取原圖
If err>0 Then
Response.Write ("對不起,獲取需要處理的圖片文件失敗!")
Response.End()
End if
Obj.Width = sWidth'//加入圖片的原寬度
Obj.Height = sHeight'//加入圖片的原高度
'\\如果原圖比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'//文字的顏色
Object.Canvas.Font.Family = "Verdana"'//文字的字體
Object.Canvas.Font.Bold = True'//是否加粗
Object.Canvas.Print 10, 10, "www.Sditi.com"'//打印坐標x 打印坐標y 需要打印的字符 Object.Canvas.Pen.Color = &H000000'//背景顏色
Object.Canvas.Pen.Width = 1'//畫筆寬度
Object.Canvas.Brush.Solid = False'//是否加粗處理
Object.Canvas.Bar 0, 0, Object.Width, Object.Height'//起始X坐標 起始Y坐標 輸入長度 輸入高度
Else
If strDo="yes" Then
Object.Canvas.Pen.Color? = &HFFFFFF'// 邊框的顏色
Object.Canvas.Pen.Width? = 0'// 邊框的粗細
Object.Canvas.Brush.Solid = false'// 圖片邊框內是否填充顏色
Object.DrawImage Object.Width/2, Object.Height/2, Obj, 0.7, &HFFFFFF,90 '// 加入圖片的位置以及坐標,透明度(添加水印圖片)
Object.Canvas.Bar 0, 0, Object.Width, Object.Height'// 圖片邊框線的位置坐標
Object.Width = Object.Width
Object.height = Object.height
Object.Sharpen 1, 120
End if
End If
Object.Save Server.MapPath(imagename)'// 生成文件
Set Obj=Nothing
End Sub
%>
Call CreateView("UploadFile/f.jpg","1")
'CreateView(原圖路徑,文字/圖象水印) '----------------------------------
'創建預覽圖片及打水印:call CreateView(文件的路徑,要添加的水印圖片文件)
'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文件
sWidth = "147"'//LOGO的寬
sHeight = "52"'//LOGO的高 LogoPath = Server.MapPath(img)'//LOGO路徑
Set Obj = Server.CreateObject("Persits.Jpeg")'//建立LOGO對象
Set Object = Server.CreateObject("Persits.Jpeg")'//建立原圖對象
On Error resume Next
Obj.Open LogoPath'//讀取LOGO
If err>0 Then
Response.Write ("對不起,獲取LOGO圖片文件失敗!")
Response.End()
End if
Object.Open Trim(Server.MapPath(imagename))'//讀取原圖
If err>0 Then
Response.Write ("對不起,獲取需要處理的圖片文件失敗!")
Response.End()
End if
Obj.Width = sWidth'//加入圖片的原寬度
Obj.Height = sHeight'//加入圖片的原高度
'\\如果原圖比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'//文字的顏色
Object.Canvas.Font.Family = "Verdana"'//文字的字體
Object.Canvas.Font.Bold = True'//是否加粗
Object.Canvas.Print 10, 10, "www.Sditi.com"'//打印坐標x 打印坐標y 需要打印的字符 Object.Canvas.Pen.Color = &H000000'//背景顏色
Object.Canvas.Pen.Width = 1'//畫筆寬度
Object.Canvas.Brush.Solid = False'//是否加粗處理
Object.Canvas.Bar 0, 0, Object.Width, Object.Height'//起始X坐標 起始Y坐標 輸入長度 輸入高度
Else
If strDo="yes" Then
Object.Canvas.Pen.Color? = &HFFFFFF'// 邊框的顏色
Object.Canvas.Pen.Width? = 0'// 邊框的粗細
Object.Canvas.Brush.Solid = false'// 圖片邊框內是否填充顏色
Object.DrawImage Object.Width/2, Object.Height/2, Obj, 0.7, &HFFFFFF,90 '// 加入圖片的位置以及坐標,透明度(添加水印圖片)
Object.Canvas.Bar 0, 0, Object.Width, Object.Height'// 圖片邊框線的位置坐標
Object.Width = Object.Width
Object.height = Object.height
Object.Sharpen 1, 120
End if
End If
Object.Save Server.MapPath(imagename)'// 生成文件
Set Obj=Nothing
End Sub
%>
總結
以上是生活随笔為你收集整理的通用 图片/文字 水印函数的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 手机软件:杀手游戏的法官助手,(人多的时
- 下一篇: 今天是个特别的日子