一聚教程网:一个值得你收藏的教程网站

热门教程

asp aspjpeg图片增加图片水印代码

时间:2022-06-30 11:07:11 编辑:袖梨 来源:一聚教程网

图片水印
 ' intdirection:图片位置:
 ' 如果传进来的是数组 array(left,top):
 '  left 表示水印图片相对源图的左上角x方向距离
 '  top 表示水印图片相对源图的左上角y方向距离
 ' 如果是单一数字:
 '  1:左上 2:上中 3:右上 4:左中 5:中中 6:右中 7:左下 8:中下 9:右下
 ' strfilename:用做水印图片的文件名
 public sub drawimage(intdirection,strfilename)
  dim objjpeg2
  dim intwidth
  dim intheight
  dim intleft
  dim inttop
  
  message = ""
  if fileisopen then
   if objfso.fileexists(server.mappath(strfilename)) then
    on error resume next
    set objjpeg2 = server.createobject("persits.jpeg")
    with objjpeg2
     .open server.mappath(strfilename)
     if err then
      message = err.description
     end if
     if intjpegor intjpegthen
      intwidth = .originalwidth
      intheight = .originalheight
     else
      intwidth = intjpegwidth
      intheight = intjpegheight
     end if
     if intwidth       if not isarray(intdirection) then
       select case intdirection
       case 1
        intleft = 0
        inttop = 0
       case 2
        intleft = (width-intwidth)/2
        inttop = 0
       case 3
        intleft = width-intwidth
        inttop = 0
       case 4
        intleft = 0
        inttop  = (height-intheight)/2
       case 5
        intleft = (width-intwidth)/2
        inttop = (height-intheight)/2
       case 6
        intleft = width-intwidth
        inttop  = (height-intheight)/2
       case 7
        intleft = 0
        inttop  = height-intheight
       case 8
        intleft = (width-intwidth)/2
        inttop  = height-intheight
       case else
        intleft = width-intwidth
        inttop  = height-intheight
       end select
      else
       intleft = intdirection(0)
       inttop = intdirection(1)
      end if
      on error resume next
      objjpeg.drawimage intleft,inttop,objjpeg2,floatjpegopacity,intjpegcolor
      if err then
       message = "打图片水印出错!"
      end if
     else
      message = "水印图片像素过大!"
     end if
    end with
   else
    message = "水印图片不存在!"
   end if
  else
   message = "文件没有打开!"
  end if
 end sub
 %>

热门栏目