aspjpeg组件图片加文字图片水印 在线图片剪切 比例放大缩小图片(1/3)
asp教程jpeg组件图片加文字图片水印 在线图片剪切 比例放大缩小图片。
'本文章是一款aspjpeg组件对图片进行图片加文字图片水印 在线图片剪切 比例放大缩小图片等操作。
class lyout_image
dim objjpeg ' aspjpeg 对象
dim objfso ' 文件读写对象
dim intimagewidth ' 图像宽度
dim intimageheight ' 图像高度
dim strmessage ' 当作操作信息
dim flagopen ' 文件打开标志
dim intjpegwidth ' 水印区域宽度
dim intjpegheight ' 水印区域高度
dim intjpegcolor ' 水印文字颜色或水印图片透明色
dim strjpegfamily ' 水印文字字体
dim flagjpegbold ' 水印文字是否粗体
dim intjpegsize ' 水印文字大小
dim floatjpegopacity ' 水印图片透明度
public property get width()
width = intimagewidth
end property
public property get height()
height = intimageheight
end property
public property let message(byval strmsg)
strmessage = strmsg
end property
public property get message()
message = strmessage
end property
public property get fileisopen()
fileisopen = flagopen
end property
public property let jpegwidth(byval intwidth)
intjpegwidth = intwidth
end property
public property let jpegheight(byval intheight)
intjpegheight = intheight
end property
public property let jpegcolor(byval intcolor)
intjpegcolor = intcolor
end property
public property let jpegfamily(byval st易做图mily)
strjpegfamily = st易做图mily
end property
public property let jpegbold(byval flagbold)
flagjpegbold = cbool(flagbold)
end property
public property let jpegsize(byval intsize)
intjpegsize = intsize
end property
public property let jpegopacity(byval floatopacity)
floatjpegopacity = floatopacity
end property
private sub class_initialize
on error resume next
intimagewidth = 0
intimageheight = 0
strmessage = ""
flagopen = false
intjpegcolor = &hffffff
strjpegfamily = "arial"
flagjpegbold = true
intjpegsize = 20
floatjpegopacity = 1
intjpegwidth = 0
intjpegheight = 0
set objjpeg = server.createobject("persits.jpeg")
if err then
set objjpeg = nothing
message = "组件 persits.jpeg 没有安装!"
exit sub
end if
message = ""
set objfso = server.createobject("scripting.filesystemobject")
if err then
set objfso = nothing
message = "组件 scripting.filesystemobject 没有安装!"
exit sub
end if
end sub
' 打开文件 strfilename
public function open(strfilename)
open = false
message = ""
if not fileisopen then
on error resume next
if objfso.fileexists(server.mappath(strfilename)) then
objjpeg.open server.mappath(strfilename)
if err then
message = err.description&"<br>"
exit function
end if
intimagewidth = objjpeg.originalwidth
intimageheight = objjpeg.originalheight
open = true
flagopen = true
message = "文件打开成功!"
else
message = "文件不存在!"
end if
else
message = "文件已打开!"
end if
end function
' 保存到文件 destfile
public sub saveas(destfile)
message = ""
on error resume next
if fileisopen then
objjpeg.save server.mappath(destfile)
if err then
message = err.description
end if
else
message = "文件已经保存!"
end if
end sub
' 关闭对象
public sub close()
on error resume next
if fileisopen then
objjpeg.close
flagopen = false
end if
end sub
1 2 3
补充:asp教程,技巧与性能优化