📄 upload_watermark.asp
字号:
<%
class CMS_WaterMark
private wobj
private base_color
private base_ycolor
private create_true
public con_filename,con_filename2,con_text,con_watermark,con_color,con_font,con_err,con_ycolor,con_setx,con_sety
public con_mode,base_width,base_height,pic_width,pic_height,wm_width,wm_height,con_width,con_height,con_place,con_quality,con_opacity,con_rotate,con_textheight,base_setx,base_sety
public con_bold
private sub class_initialize()
create_true=false
con_watermark="images/watermark.bmp"
base_color="ff0000"
base_ycolor="000000"
con_font="Courier New"
con_mode=1
base_width=20
base_height=20
base_setx=1
base_sety=1
pic_width=0
pic_height=0
wm_width=44
wm_height=35
con_place=1 '0:中间 1:左上 2:右上 3:左下 4:右下
con_quality=75
con_opacity=70
con_rotate=0
con_textheight=20
con_bold=false
end sub
public sub create_watermark()
if con_filename="" then exit sub
con_width=base_width
con_height=base_height
con_setx=base_setx
con_sety=base_sety
con_watermark=Trim(Server.MapPath(con_watermark))
con_filename=Trim(Server.MapPath(con_filename))
if con_filename2="" or isnull(con_filename2) then
con_filename2=con_filename
else
con_filename2=Trim(Server.MapPath(con_filename2))
end if
if not isnumeric(con_mode) then con_mode=0
if len(con_color)<>6 then con_color=base_color
con_color="&H"&con_color
if len(con_ycolor)<>6 then con_ycolor=base_ycolor
con_ycolor="&H"&con_ycolor
if con_font="" then con_font=base_font
on error resume next
select case int(con_mode)
case 1
call watermark_txt()
case 2
call watermark_img()
case 3
call watermark_img2()
end select
set wobj=nothing
if err then err.clear
end sub
private sub watermark_txt() 'AspJpeg 组件 文字水印
if con_text="" then exit sub
set wobj=Server.CreateObject("Persits.Jpeg")
if err then exit sub
wobj.Open con_filename
if err then exit sub
pic_width=wobj.OriginalWidth
pic_height=wobj.OriginalHeight
wm_width=len(con_text)*13
wm_height=20
call load_place_size()
if create_true=false then exit sub
wobj.Canvas.Font.Color=con_color
wobj.Canvas.Font.Family=con_font
wobj.Canvas.Font.Bold=con_bold
wobj.Canvas.Font.ShadowColor=con_ycolor '阴影颜色
wobj.Canvas.Font.ShadowXOffset=int(con_setx) '相对主字体X坐标
wobj.Canvas.Font.ShadowYOffset=int(con_sety) '相对主字体Y坐标
wobj.Canvas.Print con_width,con_height,con_text
wobj.Save con_filename2
end sub
private sub watermark_img() 'wsImage 组件 图片水印
if con_watermark="" then exit sub
set wobj=server.CreateObject("wsImage.Resize")
if err then exit sub
wobj.LoadSoucePic cstr(con_filename)
if err then exit sub
wobj.GetSourceInfo pic_width,pic_height
call load_place_size()
if create_true=false then exit sub
wobj.LoadImgMarkPic cstr(con_watermark)
if err then exit sub
wobj.Quality=con_quality
wobj.AddImgMark cstr(con_filename2),int(con_width),int(con_height),&hFFFFFF,int(con_opacity)
con_err=wobj.errorinfo
wobj.free
end sub
private sub watermark_img2() 'AspJpeg 组件 图片水印
if con_watermark="" then exit sub
dim wobj2,img_opacity
img_opacity=1-int(con_opacity)/100
set wobj=server.CreateObject("Persits.Jpeg")
if err then exit sub
wobj.Open con_filename
if err then exit sub
pic_width=wobj.OriginalWidth
pic_height=wobj.OriginalHeight
call load_place_size()
if create_true=false then exit sub
set wobj2=server.CreateObject("Persits.Jpeg")
wobj2.Open con_watermark
wobj2.Width=wm_width
wobj2.Height=wm_height
wobj2.Sharpen 1,120
wobj.DrawImage int(con_width),int(con_height),wobj2,img_opacity
wobj.Save con_filename2
wobj2.free
wobj.free
end sub
private sub load_place_size()
if int(pic_width)=0 or int(pic_height)=0 then exit sub
if int(pic_width)<int(wm_width+con_width*2) or int(pic_height)<int(wm_height+con_height*2) then exit sub
select case int(con_place)
case 0
con_width=cint((pic_width-wm_width)/2)
con_height=cint((pic_height-wm_height)/2)
case 2
con_width=pic_width-wm_width-base_width
case 3
con_height=pic_height-wm_height-base_height
case 4
con_width=pic_width-wm_width-base_width
con_height=pic_height-wm_height-base_height
end select
create_true=true
end sub
end class
%>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -