asp图片加水印,asp图片上传时自动加水印,网站设计

2013 年 11 月 26 日3720

asp图片加水印,asp图片上传时自动加水印

方法比较笨哦,呵呵, 直接在上传类文件里加上下面的两个函数,第一个是添加文字水印,第二个是添加图片水印,引用方法就是当图片上传完后调用其中某一个函数就行了.
调用方法:AddPersitsText("要加水印的图片路径及名称"), AddPersitsJpeg("要加水印的图片路径及名称")


程序代码
Public Function AddPersitsText(Path)
'************加文字水印**********************
Dim Jpeg
Set Jpeg = Server.CreateObject("Persits.Jpeg")
Jpeg.Open Server.MapPath(Path) '打开图片,Path为路片路径及名称
Jpeg.Canvas.Font.Color = &HFFFFFF '后6位为文字颜色
Jpeg.Canvas.Font.Family = "宋体" '文字字体
Jpeg.Canvas.Font.Bold = True '是否加粗
Jpeg.Canvas.Font.Size = 30 '字体大小
Jpeg.Canvas.Font.Quality = 2
Jpeg.Canvas.Font.ShadowXOffset = 1
Jpeg.Canvas.Font.ShadowYOffset = 1 '阴影效果
Jpeg.Canvas.Pen.Color = &HFFFFFF '水印背景颜色
Jpeg.Canvas.Pen.Width = 3
Jpeg.Canvas.Brush.Solid = False
Jpeg.Canvas.Print (Jpeg.width-240)/2, Jpeg.height/2+30, "http://www.zjjv.com/" '水印显示在图片上的XY位置
Jpeg.Save Server.MapPath(Path) '保存水印图片
Set Jpeg = Nothing
End Function

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("../images/imglogo.gif") '水印图片的路径
Logo.Open LogoPath
Logo.Width = 300 '水印图片的宽度
Logo.Height = Logo.Width * Logo.OriginalHeight / Logo.OriginalWidth
Photo.Canvas.Pen.Color = &H000000 '水印背景颜色
Photo.Canvas.Pen.Width = 1
Photo.Canvas.Brush.Solid = False
Photo.DrawImage (photo.width-350)/2, photo.height/2+30, Logo,0.1
photo.Save Server.MapPath(Path) ''水印显示在图片上的XY位置
Set logo = Nothing
Set photo = Nothing
End Function

0 0