AspJpeg综合操作类的

<
AspJpeg集成操作类
类AspJpeg
昏暗的aspjpeg_obj,obj
私人img_mathpath_from,img_mathpath_to,img_reduce_size,CoverIf
私人img_frame_size,img_frame_color,img_frame_solid,img_frame_width,img_frame_height
私人img_font_content,img_font_family,img_font_color,img_font_quality,img_font_size,img_font_bold,img_font_x,img_font_y
私人img_picin_path,img_picin_x,img_picin_y
--------------原文件路径
公共财产让mathpathfrom(strtype)
img_mathpath_from = strtype
最后的财产

以--------------文件路径
公共财产让mathpathto(strtype)
img_mathpath_to = strtype
最后的财产

是否覆盖现有文件的--------------保存文件
公共财产让CovePro(lngsize)
如果lngsize = 0或lngsize = 1或lngsize = TRUE或lngsize = FALSE然后
coverif = lngsize
最后如果
最后的财产

以---------------缩略图/放大缩略图的价值
公共财产让reducesize(lngsize)
如果ISNUMERIC(lngsize)然后
img_reduce_size = lngsize
最后如果
最后的财产

---------------以卒中性质
框得又粗又薄
公共财产让帧大小(lngsize)
如果ISNUMERIC(lngsize)然后
img_frame_size = Clng(lngsize)
最后如果
最后的财产
边框宽度
公共财产让frameWidth(lngsize)
如果ISNUMERIC(lngsize)然后
img_frame_width = CLNG(lngsize)
最后如果
最后的财产
框架高度
公共财产让frameHeight(lngsize)
如果ISNUMERIC(lngsize)然后
img_frame_height = CLNG(lngsize)
最后如果
最后的财产
边框颜色
公共财产让边框颜色(strtype)
如果strtype <> 然后
img_frame_color = strtype
最后如果
最后的财产
边界是否增厚
公共财产让framesolid(lngsize)
如果lngsize = 1或lngsize = 0或lngsize = TRUE或lngsize = FALSE然后
img_frame_solid = lngsize
最后如果
最后的财产

---------------插入文本属性
插入文本
公共财产让内容(strtype)
如果strtype <> 然后
img_font_content = strtype
最后如果
最后的财产
文本字体
公共财产让FontFamily(strtype)
如果strtype <> 然后
img_font_family = strtype
最后如果
最后的财产
文本颜色
公共财产让FontColor(strtype)
如果strtype <> 然后
img_font_color = strtype
最后如果
最后的财产
品格素质
公共财产让fontquality(lngsize)
如果ISNUMERIC(lngsize)然后
img_font_quality = Clng(lngsize)
最后如果
最后的财产
字长
公共财产让FontSize(lngsize)
如果ISNUMERIC(lngsize)然后
img_font_size = Clng(lngsize)
最后如果
最后的财产
文本是否加厚
公共财产让FontBold(lngsize)
如果lngsize = 1或lngsize = 0或lngsize = TRUE或lngsize = FALSE然后
img_font_bold = lngsize
最后如果
最后的财产
输入文本的x坐标
公共财产让FontX(lngsize)
如果ISNUMERIC(lngsize)然后
img_font_x = CLNG(lngsize)
最后如果
最后的财产
输入文本的y坐标
公共财产让FontY(lngsize)
如果ISNUMERIC(lngsize)然后
img_font_y = CLNG(lngsize)
最后如果
最后的财产

以---------------插入图片的属性
插入图片的路径
公共财产让PicInPath(strtype)
Img_PicIn_Path=strType
最后的财产
图像插入x坐标
公共财产让PicInX(lngsize)
如果ISNUMERIC(lngsize)然后
img_picin_x = CLNG(lngsize)
最后如果
最后的财产
图像插入y坐标
公共财产让PicInY(lngsize)
如果ISNUMERIC(lngsize)然后
img_picin_y = CLNG(lngsize)
最后如果
最后的财产


私有子class_initialize()
集aspjpeg_obj = CreateObject(很。JPEG )
img_mathpath_from =
img_mathpath_to =
img_reduce_size = 150
img_frame_size = 1
img_frame_width = 0
img_frame_height = 0
img_frame_color =h000000
img_frame_bold = false
img_font_content =金叶
img_font_family =宋体
img_font_color =h000000
img_font_quality = 3
img_font_size = 14
img_font_bold = false
img_font_x = 10
img_font_y = 5
img_picin_x = 0
img_picin_y = 0
coverif = 1

端子
私有子class_terminate()
呃。清晰
集aspjpeg_obj =没有
端子
判决书是否存在
私有函数文件(路径)
集FSOS = server.createobject(脚本。FileSystemObject )
文件= fsos.fileexists(路径)
集FSOS =没有
端功能

目录是否存在
私有函数FolderIs(路径)
集FSOS = server.createobject(脚本。FileSystemObject )
folderis = fsos.folderexists(路径)
集FSOS =没有
端功能
*******************************************
函数:获取当前文件的第一级路径。
*******************************************
私有函数UpDir(ByVal D)
如果Len(d)=0
updir =
其他的
updir =左(D,instrrev(d,)- 1)
最后如果
端功能

私有函数误差(errors_id)
选择案例errors_id
案例0
错误指定的文件不存在
案例1
错误指定的目录不存在
案例2
错误已经具有相同的名称文件
案例3
错误=参数溢出
End select
端功能


把图片宽度
公共功能imginfo_width(img_mathpath)
如果不是(文件(img_mathpath))然后
退出功能
imginfo_width =错误(0)
其他的
aspjpeg_obj.open img_mathpath
imginfo_width = aspjpeg_obj.width
最后如果
端功能
拍摄图片高度
公共功能imginfo_height(img_mathpath)
如果不是(文件(img_mathpath))然后
退出功能
imginfo_height =错误(0)
其他的
aspjpeg_obj.open img_mathpath
imginfo_height = aspjpeg_obj.height
最后如果
端功能
生成缩略图/映射
公共功能img_reduce()
如果不是(文件(img_mathpath_from))然后
img_reduce =错误(0)
退出功能
最后如果
如果不是(folderis(updir(img_mathpath_to)))然后
img_reduce =错误(1)
退出功能
最后如果
如果coverif = 0或coverif = false
如果文件(img_mathpath_to)然后
img_reduce =错误(2)
退出功能
最后如果
最后如果
aspjpeg_obj.open img_mathpath_from
aspjpeg_obj.preserveaspectratio =真
如果aspjpeg_obj originalwidth > aspjpeg_obj.originalheight然后。
aspjpeg_obj宽度= img_reduce_size。
其他的
aspjpeg_obj高度= img_reduce_size。
最后如果
如果aspjpeg_obj。originalwidth > img_reduce_size或aspjpeg_obj originalheight > img_reduce_size然后。
如果aspjpeg_obj。宽度<img_reduce_size或aspjpeg_obj高度<img_reduce_size然后。
集aspjpeg_obj_new = CreateObject(很。JPEG )
aspjpeg_obj_new.new img_reduce_size,img_reduce_size,hffffff
aspjpeg_obj_new.drawimage(150-aspjpeg_obj。宽度)/ 2、(150-aspjpeg_obj。高度)/ 2,aspjpeg_obj
如果img_frame_size > 0
电话img_pen(aspjpeg_obj_new)
最后如果
如果img_font_content <> 然后
img_font_x = aspjpeg_obj_new宽度 / 2。
img_font_y = aspjpeg_obj_new.height-15
电话img_font(aspjpeg_obj_new)
最后如果
aspjpeg_obj_new.sharpen 1, 130
aspjpeg_obj_new.save img_mathpath_to
集aspjpeg_obj_new =没有
其他的
如果img_frame_size > 0
电话img_pen(aspjpeg_obj)
最后如果
如果img_font_content <> 然后
img_font_x = aspjpeg_obj宽度 / 2。
img_font_y = aspjpeg_obj.height-15
电话img_font(aspjpeg_obj)
最后如果
aspjpeg_obj.sharpen 1, 130
aspjpeg_obj.save img_mathpath_to
最后如果
其他的
如果img_frame_size > 0
电话img_pen(aspjpeg_obj)
最后如果
如果img_font_content <> 然后
img_font_x = aspjpeg_obj宽度 / 2。
img_font_y = aspjpeg_obj.height-15
电话img_font(aspjpeg_obj)
最后如果
aspjpeg_obj.sharpen 1, 130
aspjpeg_obj.save img_mathpath_to
最后如果
端功能
生成水印
公共功能img_watermark()
如果不是(文件(img_mathpath_from))然后
img_watermark =错误(0)
退出功能
最后如果
如果img_mathpath_to = 然后
img_mathpath_to = img_mathpath_from
不(folderis(updir(img_mathpath_to)))然后
img_watermark =错误(1)
退出功能
最后如果
如果coverif = 0或coverif = false
如果img_mathpath_to <> img_mathpath_from和文件(img_mathpath_to)然后
img_watermark =错误(2)
退出功能
最后如果
最后如果
aspjpeg_obj.open img_mathpath_from
如果img_picin_path <> 然后
如果不是(文件(img_picin_path))然后
img_watermark =错误(0)
退出功能
最后如果
集aspjpeg_obj_new = CreateObject(很。JPEG )
aspjpeg_obj_new.open img_picin_path
aspjpeg_obj.preserveaspectratio =真
aspjpeg_obj_new.preserveaspectratio =真
如果aspjpeg_obj。originalwidth < img_reduce_size或aspjpeg_obj originalheight < img_reduce_size然后。
img_watermark =错误(3)
退出功能
最后如果
如果aspjpeg_obj_new originalwidth > aspjpeg_obj_new.originalheight然后。
aspjpeg_obj_new宽度= img_reduce_size。
其他的
aspjpeg_obj_new高度= img_reduce_size。
最后如果
如果img_picin_x = 然后img_picin_x = aspjpeg_obj.width-aspjpeg_obj_new.width
如果img_picin_y = 然后img_picin_y = aspjpeg_obj.height-aspjpeg_obj_new.height
aspjpeg_obj.drawimage img_picin_x,img_picin_y,aspjpeg_obj_new
集aspjpeg_obj_new =没有
最后如果
如果img_frame_size > 0
电话img_pen(aspjpeg_obj)
最后如果
如果img_font_content <> 然后
电话img_font(aspjpeg_obj)
最后如果
aspjpeg_obj.sharpen 1, 130
aspjpeg_obj.save img_mathpath_to
端功能
生成框架
私有函数img_pen(obj)
如果img_frame_width = 0然后img_frame_width = obj.width
如果img_frame_height = 0然后img_frame_height = obj.height
obj.canvas.pen.color = img_frame_color
obj.canvas.pen.width = img_frame_size
obj.canvas.brush.solid = img_frame_solid
obj.canvas.bar 1,1,img_frame_width,img_frame_height
端功能
生成水印词
私有函数img_font(obj)
obj.canvas.font.color = img_font_color
obj.canvas.font.family = img_font_family
obj。帆布质量= img_font_quality。字体。
obj。帆布。字体大小= img_font_size。
obj.canvas.font.bold = img_font_bold
obj.canvas.print img_font_x,img_font_y,img_font_content
端功能
类的结束
%>
这个类可以公开调用。
1。imginfo_height拿起图片的高度
2。imginfo_width带图片的宽度
调用方法:
复制代码代码如下所示:
昏暗的newobj,pic_h,pic_w
集newobj =新AspJpeg
pic_h = newobj.imginfo_height(F: /测试。jpg)
pic_w = newobj.imginfo_width(F: /测试。jpg)
集newobj =没有
响应。写这张图片的高度pic_h
响应。写这张图片的宽度是pic_w
反应结束

三.img_reduce来缩小或放大和保存指定的图片(你可以选择是否添加水印或不加框)
你必须定义声明mathpathfrom,MathPathTo
默认是缩放的时间模式,如果模式是小于这个尺寸,空白的图片补充。
默认文件自动覆盖
例子:
复制代码代码如下所示:
Dim NewObj, NewCommand
集newobj =新AspJpeg
newobj。mathpathfrom =F: /测试。JPG
newobj。mathpathto =F: /减少。JPG
newcommand = newobj.img_reduce
集newobj =没有
如果NewCommand <> 然后
响应。写成功
其他的
这张照片的操作出错了。
响应。写入失败
最后如果

4。img_watermark加入水印到指定的图片
水印可以组合为图片文本或2文本。