指引网

当前位置: 主页 > 编程开发 > ASP >

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

来源:网络 作者:佚名 点击: 时间:2017-06-22 20:39
[摘要] 图片水印 ' intdirection:图片位置: '如果传进来的是数组 array(left,top): 'left 表示水印图片相对源图的左上角x方向距离 'top 表示水印图片相对源图的左上角y方向距离 '如果是单一数字: '

图片水印
 ' 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 intjpegwidth = 0 or intjpegheight = 0 then
      intwidth = .originalwidth
      intheight = .originalheight
     else
      intwidth = intjpegwidth
      intheight = intjpegheight
     end if
     if intwidth<width and intheight<height then
      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
 %>

------分隔线----------------------------