ImageClass.asp
上传用户:qfkgdy
上传日期:2020-06-18
资源大小:1888k
文件大小:6k
- <%
- Class ImageClass
-
- Private Sub Class_Initialize
-
- End Sub
-
- Sub zoom2(ByVal path,ByVal spath,ByVal width,ByVal height)
- Call (new FileClass).copy(path,spath)
- End Sub
-
- '====== 缩略图 ======
- 'path:原始图路径
- 'path2:缩略图路径
- 'width:缩略图宽
- 'height:缩略图高
- Sub zoom(ByVal path,ByVal spath,ByVal width,ByVal height)
- Dim objJpeg,intWidth,intHeight
- Set objJpeg=Server.CreateObject("Persits.Jpeg")
- path=Server.MapPath(path)
- objJpeg.Open path
- if(objJpeg.originalWidth>width) then
- intWidth = width
- intHeight=objJpeg.originalHeight*width/objJpeg.originalWidth
- else
- intWidth=objJpeg.originalWidth
- intHeight=objJpeg.originalHeight
- end if
- ' if(intHeight>height) then
- ' objJpeg.width=intWidth*height/intHeight
- ' objJpeg.height=height
- ' else
- ' objJpeg.width=intWidth
- ' objJpeg.height=intHeight
- ' end if
- objJpeg.width=width
- objJpeg.height=height
-
-
- if(spath="") then
- spath=path
- else
- spath=Server.MapPath(spath)
- end if
- objJpeg.save spath
- Set objJpeg=nothing
- End Sub
-
- '====== 打水印 ======
- 'path:原始图路径
- 'wpath:生成图路径,若为空则覆盖原始图。
- 'text:水印文字
- 'position:水印位置,0为自定义;1为左上角;2为右上角;3为左下角;4为右下角;5为居中。
- 'px:左右移位,若position为0则为水印X坐标。
- 'py:上下移位,若position为0则为水印Y坐标。
- 'font_color:文字颜色
- 'font_family:文字字体
- 'font_size:文字字号
- 'font_bold:是否加粗
- 'font_shadow:文字阴影颜色,为空则不加阴影。
- 'font_background:文字背景颜色,为空则不加背景。
- Sub water(ByVal path,ByVal wpath,ByVal text,ByVal position,ByVal px,ByVal py,ByVal font_color,ByVal font_family,ByVal font_size,ByVal font_bold,ByVal font_shadow,ByVal font_background)
- Dim objJpeg
- Set objJpeg=Server.CreateObject("Persits.Jpeg")
- path=Server.MapPath(path)
- objJpeg.Open path
- if(wpath<>"") then
- path=Server.MapPath(wpath)
- end if
- if(font_color="") then font_color="FFFFFF"
- font_color="&H"&font_color
- if(font_family="") then font_family="verdana"
- if(font_size="" or font_size=0) then font_size=12
- if(font_bold="") then
- font_bold=true
- else
- font_bold=false
- end if
- if(font_bold="true") then font_bold=true
- objJpeg.Canvas.Font.color=font_color
- objJpeg.Canvas.Font.family=font_family
- objJpeg.Canvas.Font.size=font_size
- objJpeg.Canvas.Font.bold=font_bold
- if(font_shadow<>"") then
- objJpeg.Canvas.Font.shadowColor="&H"&font_shadow
- objJpeg.Canvas.Font.shadowXoffset=1 '水印文字阴影向右偏移的像素值,输入负值则向左偏移。
- objJpeg.Canvas.Font.shadowYoffset=1 '水印文字阴影向下偏移的像素值,输入负值则向右偏移。
- end if
- objJpeg.Canvas.Font.quality=4 '水印文字的清晰度,从0~4
- if(font_background<>"") then
- objJpeg.Canvas.Font.BkColor="&H"&font_background
- objJpeg.Canvas.Font.BkMode="Opaque"
- end if
- Dim font_width,font_height,px2,py2
- font_width=len(text)*(font_size/2)
- font_height=font_size
- select case position
- case 0:px2=px:py2=py
- case 1:px2=0+px:py2=0+py
- case 2:px2=objJpeg.width-font_width-px:py2=0+py
- case 3:px2=0+px:py2=objJpeg.height-font_height-py
- case 4:px2=objJpeg.width-font_width-px:py2=objJpeg.height-font_height-py
- case 5:px2=(objJpeg.width-font_width)/2:py2=(objJpeg.height-font_height)/2
- end select
- objJpeg.Canvas.print px2,py2,text
- '====== 边框 ======
- 'objJpeg.Canvas.Pen.color=&H000000 '画笔颜色
- 'objJpeg.Canvas.Pen.width=2 '画笔宽度
- 'objJpeg.Canvas.Brush.solid=false '加粗
- 'objJpeg.Canvas.Bar 1,1,objJpeg.width,objJpeg.height
- '====== 边框 ======
- objJpeg.save path
- Set objJpeg=nothing
- End Sub
-
- '====== 图片合并 ======
- 'path:原始图路径
- 'path2:图片水印路径
- 'wpath:生成图路径,若为空则覆盖原始图。
- 'position:水印位置,0为自定义;1为左上角;2为右上角;3为左下角;4为右下角;5为居中。
- 'px:左右移位,若position为0则为水印X坐标。
- 'py:上下移位,若position为0则为水印Y坐标。
- 'width:水印图片宽度,若为空则保持原始尺寸;高度按比例缩放。
- 'transparent:是否为透明水印
- 'opacity:透明度(0-1),0为完全透明;1为不透明。
- Sub com(ByVal path,ByVal path2,ByVal wpath,ByVal position,ByVal px,ByVal py,ByVal width,ByVal transparent,ByVal opacity)
- Dim objJpeg,objJpeg2
- Set objJpeg=Server.CreateObject("Persits.Jpeg")
- path=Server.MapPath(path)
- objJpeg.Open path
- if(wpath<>"") then
- path=Server.MapPath(wpath)
- end if
- Set objJpeg2=Server.CreateObject("Persits.Jpeg")
- path2=Server.MapPath(path2)
- objJpeg2.Open path2
- if(width<>"" and width<>0) then
- objJpeg2.width=width
- objJpeg2.height=objJpeg2.width*objJpeg2.originalHeight/objJpeg2.originalWidth
- end if
- Dim px2,py2
- select case position
- case 0:px2=px:py2=py
- case 1:px2=0+px:py2=0+py
- case 2:px2=objJpeg.width-objJpeg2.width-px:py2=0+py
- case 3:px2=0+px:py2=objJpeg.height-objJpeg2.height-py
- case 4:px2=objJpeg.width-objJpeg2.width-px:py2=objJpeg.height-objJpeg2.height-py
- case 5:px2=(objJpeg.width-objJpeg2.width)/2:py2=(objJpeg.height-objJpeg2.height)/2
- end select
- if(opacity="") then
- opacity=1
- else
- opacity=opacity/100
- end if
- if(transparent) then
- transparent=&Hffffff
- end if
- '倒数第二个参数为透明度,最后一个为抽取颜色
- objJpeg.drawImage px2,py2,objJpeg2,opacity,transparent
- objJpeg.save path
- Set objJpeg2=nothing
- Set objJpeg=nothing
- End Sub
-
- Private Sub Class_Terminate
-
- End Sub
-
- End Class
- %>