Public Function AddPersitsText(Path,Font,Location)
Dim Jpeg
Set Jpeg = Server.CreateObject("Persits.Jpeg")
Jpeg.Open Server.MapPath(Path) '打开图片,Path为路片路径及名称
Jpeg.Canvas.Font.Color = &HFF0000 '后6位为文字颜色
Jpeg.Canvas.Font.Family = "黑体" '文字字体
Jpeg.Canvas.Font.Bold = True '是否加粗
Jpeg.Canvas.Font.Size = 18 '字体大小
Jpeg.Canvas.Font.Quality = 10
Jpeg.Canvas.Font.ShadowXOffset = 1
Jpeg.Canvas.Font.ShadowYOffset = 3 '阴影效果
Jpeg.Canvas.Pen.Color = &HFFFFFF '水印背景颜色
Jpeg.Canvas.Pen.Width = 3
Jpeg.Canvas.Brush.Solid = False
IF Location =0 Then
Jpeg.Canvas.Print (Jpeg.width-60)/2, (Jpeg.height-10)/2, Font '水印显示在图片上的居中位置
ElseIf Location=1 Then
Jpeg.Canvas.Print Jpeg.width-120, 20, Font '水印显示在图片上的右上位置
ElseIF Location=2 Then
Jpeg.Canvas.Print Jpeg.width-120, Jpeg.height-20, Font '水印显示在图片上的右下位置
ElseIF Location=3 Then
Jpeg.Canvas.Print 20, 20, Font '水印显示在图片上的左上位置
Else
Jpeg.Canvas.Print 20, Jpeg.height-20, Font '水印显示在图片上的左下位置
End IF
Jpeg.Save Server.MapPath(Path) '保存水印图片
Set Jpeg = Nothing
End Function
'传入的参数是需要处理的图片路径,自己根据需要可以调整参数或者加入其它的参数'文字水印
Function WordWatermark(ImagePath)
Dim Image
Set Image= Server.CreateObject("Persits.Jpeg") ' 建立对象
Image.Open server.mappath(ImagePath) ' 图片所在位置
Image.Canvas.Font.Color = &H000000 ' 颜色,这里是设置成:黑
Image.Canvas.Font.Family = "宋体" ' 设置字体
Image.Canvas.Font.Bold = False '是否设置成粗体
Image.Canvas.Font.Size = 26 '字体大小
Image.Canvas.Font.Quality = 4 ' 文字清晰度
Image.Canvas.Print Image.OriginalWidth/2-170,Image.OriginalHeight-30, "水印文字" '水印文字
Image.Save server.mappath(ImagePath) ' 保存文件
Set Image= Nothing
End Function
'图片水印
Function ImageWatermark(ImagePath)
Set Image = Server.CreateObject("Persits.Jpeg")
'确定要加入水印的图片路径
PhotoPath = Server.MapPath(ImagePath)
Image.Open PhotoPath
'打开水印图片
Set Logo = Server.CreateObject("Persits.Jpeg")
LogoPath = Server.MapPath("logo.jpg") '水印的图片
Logo.Open LogoPath
Logo.Width = 121 '水印图片的大小
Logo.Height = 50
Transition_Color = &h0066cc
'将水印放置于上传图片中
Image.DrawImage Image.width-150, Image.height-59, Logo,1,Transition_Color,90
'在这里可以更改水印所在的位置(photo.width-210,photo.height-40 这里我是放在了图片的右下角)还可以更改水印的透明度
'保存增加水印后的图片
Image.Save Server.MapPath(ImagePath)
Set Photo = Nothing
End Function
给全站图片加水印,思路是,找出网站图片目录,循环遍历该目录将里面的图片通过一个加水印函数处理,不明hi我或Q我:573780643以下为代码:
<%@LANGUAGE="VBSCRIPT" CODEPAGE="936"%>
<%
Public Function AddPersitsJpeg(Path)
'**************加图片水印*******************
Dim photo,logo,photopath,logopath
Set Photo = Server.CreateObject("Persits.Jpeg")
PhotoPath = Server.MapPath(Path) 'Path为路片路径及名称
Photo.Open PhotoPath '打开图片
Set Logo = Server.CreateObject("Persits.Jpeg")
LogoPath = Server.MapPath("logo/sinalogo.gif") '水印图片的路径(自己修改)
Logo.Open LogoPath
Logo.Width = photo.width /4 '水印图片的宽度
Logo.Height = photo.width /12
Photo.Canvas.Pen.Color = &H000000
Photo.Canvas.Pen.Width = 0
Photo.Canvas.Brush.Solid = False
Photo.DrawImage (photo.width-Logo.Width-20), photo.height-Logo.Height-10, Logo,0.6
photo.Save Server.MapPath(Path) ''水印显示在图片上的XY位置
Set logo = Nothing
Set photo = Nothing
End Function
%>
<%
Set fso=Server.CreateObject("Scripting.FileSystemObject")
dim FileName
FPath="pic/"'网站图片目录(自己修改)
Set fs = fso.GetFolder(server.MapPath(FPath))
Set f = fs.Files
For each k in f'循环目录
AddPersitsJpeg(FPath&k.name) '用AddPersitsJpeg函数给图片加水印
next
end if
%>
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)