飙血推荐
  • HTML教程
  • MySQL教程
  • JavaScript基础教程
  • php入门教程
  • JavaScript正则表达式运用
  • Excel函数教程
  • UEditor使用文档
  • AngularJS教程
  • ThinkPHP5.0教程

aspjpeg组件使用方法284455详解

时间:2023-05-16  作者:匿名  

1、什么是AspJpeg?

AspJpeg是一款功能强大的基于Microsoft IIS环境的图片处理组件,网络上对其进行详细和深入介绍的中文文章并不多,即使有一般也只是牵涉到图片缩略图和图片水印,这与其为英文版本有着密切的关系。
AspJpeg可以使用很少的代码在您的ASP/域名应用程序上动态的创建高质量的缩略图象,支持的图象格式有:JPEG, GIF, BMP, TIFF, PNG

AspJpeg主要可以做到:

生成缩略图片
生成水印图片
图片合并
图片切割
数据库支持
安全码技术

2、AspJpeg功能摘要

支持JPEG, GIF, BMP, TIFF 和 PNG 格式图片. 输出格式始终为 JPEG
源图片可以来源于磁盘、内存、或者记录集(数据库)
缩略图片可以保存到磁盘、内存、或者HTTP流
支持三种更改大小方式: nearest-neighbor, bilinear, and bicubic.
可以在图片之上添加图片或者文字.
支持画中画
支持复制,反转,旋转,锐化,灰度调节.
可以调节压缩比率,以得到最佳输出效果和大小.
从Jpeg图片中抽取EXIF 和 IPTC数据.
CMYK-RGB转换
Read/write access to individual pixels of an image. (从图象中对任意象素进行读/写存取。)

3、AspJpeg系统需求

Windows 95/98/NT/2000/XP/2003, and
IIS 4.0+ and ASP/域名, or
Visual Basic 5.0+, or
Visual C++ 5.0+, or
any development environment supporting COM.

4、AspJpeg安装

全新安装:
在AspJpeg安装过程中输入序列号即可,如果安装位置磁盘格式为NTFS,则可能出现访问权限问题,需手工设置安装目录对Everyone有访问权限。
AspJpeg v1.6.0.0
安装sn:48958-77556-02411
AspJpeg v1.5.0
安装sn:71316-48529-38722

更新安装:

如果之前有装过其它版本的AspJpeg组件,则需要先卸载原来的组件,再进行新版本的安装。

先停止IIS

Net Stop iisadmin /y

卸载旧版组件

regsvr32 /u Path/域名(Path为安装路径)

重启IIS

Net Start w3svciisreset /restart

然后再进行全新安装或复制域名文件到安装目录进行手工安装:

regsvr32 Path/域名(Path为安装路径)

如果在正常安装过程中没有输入序列号或手工安装则必须在注册表中加入以下项,为方便起见您可以直接将以下代码保存为.reg文档并导入注册表:

Windows Registry Editor Version 域名

[HKEY_LOCAL_MACHINE/SOFTWARE/Persits Software/AspJpeg/RegKey]
@="48958-77556-02411"

5、如何创建一个AspJpeg实例?

Set Jpeg = 域名teObject("域名")

6、如何查看到期时间(是否注册成功)?

Set Jpeg = 域名teObject("域名")
域名e 域名res

注册成功则到期时间为:9999-9-9
否则为:安装日期加1个月期限

7、如何用AspJpeg组件生成图片缩略图?

<%
Set Jpeg = 域名teObject("域名") \'创建实例
Path = 域名ath("../images/域名") \'处理图片路径
域名 Path \'打开图片
\'调整宽度和高度为原来的50%
域名h = 域名inalWidth / 2
域名ht = 域名inalHeight / 2
域名 域名ath("域名") \'保存图片到磁盘
域名e
Set Jpeg = Nothing
%>

8、如何用AspJpeg组件生成图片水印?

<%
Set Jpeg = 域名teObject("域名")
域名 域名ath("images/域名")
\'开始写文字
域名.Color = &000000 \' red 颜色
域名.Family = "Courier New" \'字体
域名.Bold = True \'是否加粗
域名t 10, 10, "Copyright (c) http://域名/yongfa365."
\'打印坐标x 打印坐标y 需要打印的字符
\'以下是对图片进行边框处理
域名.Color = &H000000 \'black 颜色
域名.Width = 2 \'画笔宽度
域名域名d = False \'是否加粗处理
域名 1, 1, 域名h, 域名ht
\'起始X坐标 起始Y坐标 输入长度 输入高度
域名 域名ath("images/域名") \'保存
%>

9、如何用AspJpeg组件进行图片合并?

AspJpeg 1.3+ enables you to place images on top of each other via the method DrawImage. To use this method, you must create two instances of the AspJpeg objects and populate both of them with images via calls to Open (or OpenBinary). When calling 域名Image, the 2nd instance of AspJpeg is passed as an argument to this method, along with the X and Y offsets (in pixels):
使用该方法,您必需创建两个AspJpeg实例对象

<%
Set Jpeg1 = 域名teObject("域名")
Set Jpeg2 = 域名teObject("域名")
域名 域名ath("域名")
域名 域名ath("域名")
域名Image 10, 10, Jpeg2 \' optional arguments omitted
域名 域名ath("域名")
%>

10、如何用AspJpeg组件进行图片切割?

AspJpeg 1.1+ is also capable of cutting off edges from, or cropping, the resultant thumbnails via the method Crop(x0, y0, x1, y1). The size of the cropped image is specified by the coordinates of the upper-left and lower-right corners within the resultant thumbnail, not the original large image.

<%
Set Jpeg = 域名teObject("域名")
域名 域名ath("域名")
域名 20, 30, 域名h - 20, 域名ht - 10
域名 域名ath("域名")
域名e("")
%>

11、如何用AspJpeg组件创建安全码?

创建安全码原理上和创建水印差不多。

<%
Function make_randomize(max_len, w_n) \'max_len 生成长度,w_n:0 可能包含字母,1:只为数字
    Randomize
    For intcounter = 1 To max_len
        whatnext = Int((1 -0 + 1) * Rnd + w_n)
        If whatnext = 0 Then
            upper = 122
            lower = 97
        Else
            upper = 57
            lower = 48
        End If
        strnewpass = strnewpass & Chr(Int((upper - lower + 1) * Rnd) + lower)
    Next
    make_randomize = strnewpass
End Function
\'生成安全码的图片。
random_num = make_randomize(4, 1) \'\'生成4位数字的安全码
session("random_num") = random_num \'为么调用session,没有session的安全码是完全没有意义的。呵呵 .
Set Jpeg = 域名teObject("域名") \'调用组件
域名 域名ath("域名") \'打开准备的图片
域名.Color = &HFFFFFF
域名.Family = "Arial Black"
域名.Bold = false
域名tText 0, -2, random_num
域名 域名ath("域名") \'保存
%>

12、如何让AspJpeg组件支援数据库?

图片存进数据库只能以二进制数据保存,这里即利用AspJpeg的Binary方法,下面以两个AspJpeg用户手册上的代码为例,具体请参考AspJpeg用户手册:
Opening Images from Memory

<%\' Using ADO, open database with an image blob
strConnect = "DRIVER={Microsoft Access Driver (*.mdb)};DBQ=" & 域名ath("../db/域名")
Set rs = 域名teObject("域名rdset")
SQL = "select image_blob from images2 where id = " & Request("id")
域名 SQL, strConnect, 1, 3
Set Jpeg = 域名teObject("域名")
\' Open image directly from recordset
域名Binary rs("image_blob").Value
\' Resize
域名h = Request("Width")
\' Set new height, preserve original aspect ratio
域名ht = 域名inalHeight * 域名h / 域名inalWidth
域名Binary
域名e
%>

Output to Memory

<%
...
Set rs = 域名teObject("域名rdset")
域名 "images", strConnect, 1, 3
域名ew
rs("image_blob").Value = 域名ry
域名te
...
%>

一个生成文字水印的过程

<%
\'call jpegclass(图片相对路径, 文字字体大小, 文字字体, 是否加粗, 距顶部距离, 距左边距离, 水印内容)
Sub jpegclass(J_imgurl, J_fontsize, J_family, J_isbold, J_top, J_Left, J_Content) \'调用过程名
    If Len(J_imgurl) = 0 Or Len(J_Content) = 0 Then Exit Sub
    Dim JPEG, font_color, font_size, font_family, f_width, f_height, f_Content
    Set JPEG = 域名teObject("域名")
    域名 域名ath(J_imgurl)
    font_size = 10
    font_family = "宋体"
    f_Left = 5
    f_top = 5
    If J_fontsize<>"" Then font_size = J_fontsize \'字体大小
    If J_family<>"" Then font_family = J_family \'字体
    If J_top<>"" Then f_Left = J_Left \'水印离图片左边位置
    If J_Left<>"" Then f_top = J_top \'水印离图片J_top位置
    f_Content = J_Content
    \' 添加文字水印
    域名.Color = &hff0000 \' 红色
    域名.family = font_family
    域名.Size = font_size
    If J_isbold = 1 Then
        域名.Bold = True
    End If
    域名t f_Left, f_top, f_Content
    域名 域名ath(J_imgurl)
    Set JPEG = Nothing
End Sub
%>
原文地址:

标签:编程
湘ICP备14001474号-3  投诉建议:234161800@qq.com   部分内容来源于网络,如有侵权,请联系删除。