
<%
Dim Jpeg,watermarkObject,watermarkheight,watermarkwidth,watermarkimg,watermarktxt '//声明变量
Dim watermarkBond,watermarkFont,watermarksize,watermarkclr,watermarkX,watermarkY,watermarkon
set rs=server.CreateObject("adodb.recordset")
rs.Open "select *  from sdx_watermark",conn,1,1
watermarkon=rs("watermarkon")
Thumbok=rs("Thumbok")
watermarkObject=rs("watermarkObject")
watermarkheight=rs("watermarkheight")
watermarkwidth=rs("watermarkwidth")
watermarkimg=rs("watermarkimg")
watermarktxt=rs("watermarktxt")
watermarkBond=rs("watermarkBond")
watermarkFont=rs("watermarkFont")
watermarksize=rs("watermarksize")
watermarkclr= rs("watermarkclr")
watermarkshowclr= rs("watermarkshowclr")
watermarkX=rs("watermarkX")
watermarkY=rs("watermarkY")
rs.close
set rs=nothing
if watermarkon<>0 then
bpicpath="../"
LocalFile=bpicpath&filelstname
TargetFile=bpicpath&filelstname
Set Jpeg = Server.CreateObject("Persits.Jpeg") 
If Err.Number=-2147221005 then 
Response.write "没有AspJpeg水印和缩略图组件，请安装!"'检查是否安装AspJpeg组件 
Response.End() 
End If 
Jpeg.Open Server.MapPath(LocalFile) '打开图片 
If err.number then 
Response.write"打开图片失败,请检查路径！" 
Response.End() 
End if 
Dim TempA '原始图片的二进制数据
Dim TempB '加了不透明文字水印的图片
Dim TempC '最终效果
TempA=Jpeg.Binary'将原始数据赋给TempA 

'=========加文字水印================= 
Jpeg.Canvas.Font.Color = watermarkclr  '水印文字颜色 
Jpeg.Canvas.Font.Family = watermarkFont '字体 
if watermarkBond=0 then
Jpeg.Canvas.Font.Bold = False '是否加粗 
else
Jpeg.Canvas.Font.Bold = False '是否加粗 
end if
Jpeg.Canvas.Font.Size = watermarksize '字体大小 
Jpeg.Canvas.Font.ShadowColor = watermarkshowclr '阴影色彩 
Jpeg.Canvas.Font.ShadowYOffset = 1 
Jpeg.Canvas.Font.ShadowXOffset = 1
Jpeg.Canvas.Brush.Solid = True 
Jpeg.Canvas.Font.Quality = 5 '输出质量 
Jpeg.Canvas.PrintText Jpeg.OriginalWidth-watermarkX,Jpeg.OriginalHeight-watermarkY,watermarktxt '水印位置及文字 
TempB=Jpeg.Binary'将文字水印处理后的值赋给TempB，这时，文字水印没有不透明度 
'============调整文字透明度================ 
Set MyJpeg = Server.CreateObject("Persits.Jpeg") 
MyJpeg.OpenBinary TempA 
Set Logo = Server.CreateObject("Persits.Jpeg") 
Logo.OpenBinary TempB 
MyJpeg.DrawImage 0,0, Logo, 0.8 '0.3是透明度 
TempC=MyJpeg.Binary'将最终结果赋值给TempC,这时也可以生成目标图片了 
Jpeg.Save Server.MapPath(TargetFile) 
set TempA=nothing 
set TempB=nothing 
set TempC=nothing 
Jpeg.close 
Logo.Close 
MyJpeg.Close 
end if
%>
