ASP图片加水印函数
作者:天魅 日期:2008-07-22
现在做开发的,特别是企业站和产品,和门户网图片资源,都喜欢加上水印,说到底就是为了防别人下载走!不过现在有反水印的程序,好像说只要知道你加水印文字之类的信息就可以破解了.这年头反正能加就能减,道一C魔高一Z!
程序代码
Function JpegPersits
if SiteConfig("WatermarkType")=0 then
Jpeg.Canvas.Font.Color = Replace(SiteConfig("WatermarkFontColor"),"#","&h") '颜色
Jpeg.Canvas.Font.Family = SiteConfig("WatermarkFontFamily") '字体
Jpeg.Canvas.Font.size = SiteConfig("WatermarkFontSize") '大小
Jpeg.Canvas.Font.Bold = CBool(SiteConfig("WatermarkFontIsBold")) '是否加粗
'Jpeg.Canvas.Font.ShadowXoffset = 10 '水印文字阴影向右偏移的像素值,输入负值则向左偏移
'Jpeg.Canvas.Font.ShadowYoffset = 10 '水印文字阴影向下偏移的像素值,输入负值则向右偏移
Title = SiteConfig("WatermarkText")
TitleWidth = Jpeg.Canvas.GetTextExtent(Title)
if Jpeg.Width<TitleWidth then exit function '图片比水印文字小,则不加水印
select case SiteConfig("WatermarkWidthPosition")
case "left"
PositionWidth=10
case "center"
PositionWidth=(Jpeg.Width - TitleWidth) / 2
case "right"
PositionWidth= Jpeg.Width - TitleWidth - 10
end select
Jpeg.Canvas.Print PositionWidth, 10, Title
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
elseif SiteConfig("WatermarkType")=1 then
Set Jpeg2 = Server.CreateObject("Persits.Jpeg")
Jpeg2.Open Server.MapPath(SiteConfig("WatermarkImage"))
Jpeg2Width=Jpeg2.OriginalWidth
Jpeg2Height=Jpeg2.OriginalHeight
if Jpeg.Width<Jpeg2Width or Jpeg.Height<Jpeg2Height*2 then exit function '图片比水印图片小,则不加水印
select case SiteConfig("WatermarkWidthPosition")
case "left"
PositionWidth=10
case "center"
PositionWidth=(Jpeg.Width - Jpeg2Width) / 2
case "right"
PositionWidth= Jpeg.Width - Jpeg2Width - 10
end select
select case SiteConfig("WatermarkHeightPosition")
case "top"
PositionHeight=10
case "center"
PositionHeight=(Jpeg.Height - Jpeg2Height) / 2
case "bottom"
PositionHeight= Jpeg.Height - Jpeg2Height - 10
end select
Jpeg.Canvas.DrawImage PositionWidth, PositionHeight, Jpeg2, 1, &HFFFFFF '透明度, 透明颜色
end if
End Function
该文章转载自鸡立鹤群博客:http://www.leoyung.com/article/7906.htm
程序代码Function JpegPersits
if SiteConfig("WatermarkType")=0 then
Jpeg.Canvas.Font.Color = Replace(SiteConfig("WatermarkFontColor"),"#","&h") '颜色
Jpeg.Canvas.Font.Family = SiteConfig("WatermarkFontFamily") '字体
Jpeg.Canvas.Font.size = SiteConfig("WatermarkFontSize") '大小
Jpeg.Canvas.Font.Bold = CBool(SiteConfig("WatermarkFontIsBold")) '是否加粗
'Jpeg.Canvas.Font.ShadowXoffset = 10 '水印文字阴影向右偏移的像素值,输入负值则向左偏移
'Jpeg.Canvas.Font.ShadowYoffset = 10 '水印文字阴影向下偏移的像素值,输入负值则向右偏移
Title = SiteConfig("WatermarkText")
TitleWidth = Jpeg.Canvas.GetTextExtent(Title)
if Jpeg.Width<TitleWidth then exit function '图片比水印文字小,则不加水印
select case SiteConfig("WatermarkWidthPosition")
case "left"
PositionWidth=10
case "center"
PositionWidth=(Jpeg.Width - TitleWidth) / 2
case "right"
PositionWidth= Jpeg.Width - TitleWidth - 10
end select
Jpeg.Canvas.Print PositionWidth, 10, Title
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
elseif SiteConfig("WatermarkType")=1 then
Set Jpeg2 = Server.CreateObject("Persits.Jpeg")
Jpeg2.Open Server.MapPath(SiteConfig("WatermarkImage"))
Jpeg2Width=Jpeg2.OriginalWidth
Jpeg2Height=Jpeg2.OriginalHeight
if Jpeg.Width<Jpeg2Width or Jpeg.Height<Jpeg2Height*2 then exit function '图片比水印图片小,则不加水印
select case SiteConfig("WatermarkWidthPosition")
case "left"
PositionWidth=10
case "center"
PositionWidth=(Jpeg.Width - Jpeg2Width) / 2
case "right"
PositionWidth= Jpeg.Width - Jpeg2Width - 10
end select
select case SiteConfig("WatermarkHeightPosition")
case "top"
PositionHeight=10
case "center"
PositionHeight=(Jpeg.Height - Jpeg2Height) / 2
case "bottom"
PositionHeight= Jpeg.Height - Jpeg2Height - 10
end select
Jpeg.Canvas.DrawImage PositionWidth, PositionHeight, Jpeg2, 1, &HFFFFFF '透明度, 透明颜色
end if
End Function
该文章转载自鸡立鹤群博客:http://www.leoyung.com/article/7906.htm
评论: 1 | 引用: 0 | 查看次数: 1219
- 1
bbsxp的水印
- 1
发表评论
上一篇
下一篇


Tags: 





