AspJpeg介绍

上一篇 / 下一篇  2009-07-11 21:48:38 / 个人分类:日常收集

  • 文件版本: V1.0
  • 开发商: 本站原创
  • 文件来源: 本地
  • 界面语言: 简体中文
  • 授权方式: 免费
  • 运行平台: Win9X/Win2000/WinXP

  1、AspJpeg是一款功能强大的基于Microsoft IIS环境的图片处理组件,网络上对其进行详细和深入介绍的中文文章并不多,即使有一般也只是牵涉到图片缩略图和图片水印,这与其为英文版本有着密切的关系。

2Bj!`#xv*mV3b2X0

  AspJpeg可以使用很少的代码在您的ASP/ASP.Net应用程序上动态的创建高质量的缩略图象,支持的图象格式有:JPEG, GIF, BMP, TIFF, PNG。51Testing软件测试网FL mm4cQ!P9]S3^

  AspJpeg主要可以做到:生成缩略图片、生成水印图片、图片合并、图片切割、数据库支持、安全码技术

[m"b!XwUWT9V~0

  ASPJPEG是一款功能相当强大的图象处理组件,用它可以轻松地做出图片的缩略图和为图片加上水印功能。

6K&Z@ \4@1V eKX0

  安装SN:09268-26217-4071051Testing软件测试网~5y5c8Mm

  2、AspJpeg功能摘要

/Vh T5RFl0

  支持JPEG, GIF, BMP, TIFF 和 PNG 格式图片. 输出格式始终为 JPEG

3Ek%Uo-u8Nh5`0

  源图片可以来源于磁盘、内存、或者记录集(数据库)51Testing软件测试网YP(~/@t5V9\#d"S6[D

  缩略图片可以保存到磁盘、内存、或者HTTP流51Testing软件测试网6Aj cW"x;LL

  支持三种更改大小方式: nearest-neighbor, bilinear, and bicubic.

;Q1Fd9O`P8Z5o8[0

  可以在图片之上添加图片或者文字.51Testing软件测试网:[(VA:Tx

  支持画中画51Testing软件测试网].s lsrv2kLa

  支持复制,反转,旋转,锐化,灰度调节.

Q Y"mB(u{0

  可以调节压缩比率,以得到最佳输出效果和大小.51Testing软件测试网tqC sx`

  从Jpeg图片中抽取EXIF 和 IPTC数据.

/`c^w2M0D~7]q2c0

  CMYK-RGB转换

`ux!^.I`TPS0

  Read/write access to individual pixels of an image. (从图象中对任意象素进行读/写存取。)51Testing软件测试网5E&? [7T-U/r/r c'Q

  3、AspJpeg系统需求

K:W:{@"M!F m4I0

  Windows 95/98/NT/2000/XP/2003, and51Testing软件测试网3OJ7JA.`H+?D-n9J

  IIS 4.0+ and ASP/ASP.NET, or

&Fd1Q%OAUeC4?0

  Visual Basic 5.0+, or

U+Zv \(wau0

  Visual C++ 5.0+, or51Testing软件测试网$]!gH:t"U'r

  any development environment supporting COM.51Testing软件测试网|D(_E:n8v-d

  4、AspJpeg安装

(iXt [2Oo G0

  全新安装:51Testing软件测试网 I f*s*v'J%S P C"s-s$a"|$m

  在AspJpeg安装过程中输入序列号即可,如果安装位置磁盘格式为NTFS,则可能出现访问权限问题,需手工设置安装目录对Everyone有访问权限。

1facL0y!AT j6E/I0

  更新安装:51Testing软件测试网b4XkaYk+s9]

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

!q@Bq/zcx7L v0

  先停止IIS

zU`&Xcd1g3r0

  Net Stop iisadmin /y51Testing软件测试网/]|1iM [)H,[-\T T S.Lx6x

  卸载旧版组件51Testing软件测试网JM }k(fA1a

  regsvr32 /u Path/aspjpeg.dl(Path为安装路径)51Testing软件测试网 T'\%f`}(_/e.Ha4x

  重启IIS51Testing软件测试网D8KTT2iS~Q

  Net Start w3svc51Testing软件测试网8J{'rq#MIe:hA+H

  然后再进行全新安装或复制AspJpeg.dll文件到安装目录进行手工安装:51Testing软件测试网KR QmCC

  regsvr32 Path/aspjpeg.dll(Path为安装路径)

)x,l3V^,V'F0

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

h[lfc.t"B&vN*`0

  Windows Registry Editor Version 5.00

0]g5uV6] OM0

  [HKEY_LOCAL_MACHINE\SOFTWARE\Persits Software\AspUpload3\RegKey]51Testing软件测试网d#h(y7W6q I

  @="21764-40765-60456"51Testing软件测试网3m3CR6i^Y W

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

6G'_W(Gi*l(|k @3X0

  Set Jpeg = Server.CreateObject("Persits.Jpeg")51Testing软件测试网-u.W*V]9m6pC"{4?a]

  6、如何查看到期时间(是否注册成功)?51Testing软件测试网h,NhC(Fm*n~u

  Set Jpeg = Server.CreateObject("Persits.Jpeg")

l[r Odpc1h0

  Response.Write Jpeg.Expires51Testing软件测试网!M1N$zF(Ws}5_

  注册成功则到期时间为:9999-9-9

A"pO$m W nJ0

  否则为:安装日期加1个月期限

{`RX;B-TU+K i0

  7、如何用AspJpeg组件生成图片缩略图?51Testing软件测试网'aA6u1IW

  <%51Testing软件测试网Q d2s8Q%[9y-Jc.f*h j

  Set Jpeg = Server.CreateObject("Persits.Jpeg") '创建实例51Testing软件测试网?)S&~ K }\c

  Path = Server.MapPath("../images/apple.jpg") '处理图片路径51Testing软件测试网 k6rL+xfW f'hH

  Jpeg.Open Path '打开图片

;k s3Ho+P4wLyY0

  '调整宽度和高度为原来的50%51Testing软件测试网%`Z7s*kUli

  Jpeg.Width = Jpeg.OriginalWidth / 251Testing软件测试网-T Rk'P1}Gx(w

  Jpeg.Height = Jpeg.OriginalHeight / 251Testing软件测试网,V2]l[N&u ua1V

  Jpeg.Save Server.MapPath("apple_small.jpg") '保存图片到磁盘

hjz4s PG'Y \0y0

  Jpeg.Close:Set Jpeg = Nothing

4^tNm$YKR0

  %>

s-q.j2?r&`U/B0

  8、如何用AspJpeg组件生成图片水印?51Testing软件测试网%D Q [aY? be

  <%51Testing软件测试网*dB\CfL,l!GOK

  Set Jpeg = Server.CreateObject("Persits.Jpeg")

L(A @l2Dl]_,?i0

  Jpeg.Open Server.MapPath("images/dodge_viper.jpg")51Testing软件测试网2qQ5?SY&K:zCO

  开始写文字

Y;b3C]f W0

  Jpeg.Canvas.Font.Color = &000000'' red 颜色51Testing软件测试网QFX"Tq

  Jpeg.Canvas.Font.Family = "Courier New" 字体

2zv&soaB8@0

  Jpeg.Canvas.Font.Bold = True 是否加粗51Testing软件测试网a"M p;n5bJ

  Jpeg.Canvas.Print 10, 10, "Copyright (c) XYZ, Inc."

SE| sLtk+o&BlB0

  打印坐标x 打印坐标y 需要打印的字符51Testing软件测试网e S#d+S6]vKo

  以下是对图片进行边框处理51Testing软件测试网9@ v1Z6d0DK%~U3q3w&N

  Jpeg.Canvas.Pen.Color = &H000000'' black 颜色

EphH5Fl%L0

  Jpeg.Canvas.Pen.Width = 2 画笔宽度

_Rb)J#\%TH0

  Jpeg.Canvas.Brush.Solid = False 是否加粗处理51Testing软件测试网4erSA&G Z

  Jpeg.Canvas.Bar left, top, right, bottom ' 左,上,右,下51Testing软件测试网1N9B1c)gk ~

  Jpeg.Save Server.MapPath("images/dodge_viper_framed.jpg") 保存51Testing软件测试网6OL;` u Vf!Z2S1|x(`m

  %>

q+B"Zc2BVCrd s:[0

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

Lb#S7kL?/~o0

  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 Canvas.DrawImage, the 2nd instance of AspJpeg is passed as an argument to this method, along with the X and Y offsets (in pixels):

!N PViC,FL0

  使用该方法,您必需创建两个AspJpeg实例对象

%{\kJ5MnQ(Kj0

  <%

4ZJu9ldy0

  Set Jpeg1 = Server.CreateObject("Persits.Jpeg")51Testing软件测试网@N$sfnM v

  Set Jpeg2 = Server.CreateObject("Persits.Jpeg")

!Z#FV5N x4_2FH0

  Jpeg1.Open Server.MapPath("t.jpg")

T b}"E$}WT&R-u0

  Jpeg2.Open Server.MapPath("t1.jpg")51Testing软件测试网nl!pA1}

  Jpeg1.Canvas.DrawImage 10, 10, Jpeg2 ' optional arguments omitted51Testing软件测试网}E Ju,|$O_0x/Z,U

  jpeg1.save Server.mappath("tt.jpg")

W5Z,R&KYYE0

  %>

:f*@/H.P!Jm e#Q:?0

  10、如何用AspJpeg组件进行图片切割?51Testing软件测试网;zL4G5U i])B

  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.51Testing软件测试网5MC*Hl*_0U K

  <%

j ~%YVN0

  Set Jpeg = Server.CreateObject("Persits.Jpeg")

r Kf ~ cE R N7`b0M0

  Jpeg.Open Server.MapPath("t.jpg")

7Q!M*Pey!wH N0

  jpeg.Crop 20, 30, jpeg.Width - 20, jpeg.Height - 1051Testing软件测试网~,A&fC7B `

  jpeg.save Server.mappath("tt.jpg")

U;AOCJ%r%c8p B3BZ"Z0

  Response.write("<img src=tt.jpg>")

W#zHWA-vF+g0

  %>

RT3hP3S5E}0

  11、如何用AspJpeg组件创建安全码?51Testing软件测试网 o Q[:{?'~J:~

  创建安全码原理上和创建水印差不多。51Testing软件测试网z0mr|5H7g

  <%51Testing软件测试网+|"\I7z)]v,j!`

  function make_randomize(max_len,w_n) 'max_len 生成长度,w_n:0 可能包含字母,1:只为数字

BMGp{fBl9l n0

  randomize

8b1j4i nJ?Hz0

  for intcounter=1 to max_len51Testing软件测试网ywL}:L%F1T `

  whatnext=int((1-0+1)*rnd+w_n)51Testing软件测试网)fl:Q4x:X

  if whatnext=0 then

@DX.R~"~ W3V#X0

  upper=12251Testing软件测试网`5r[-i:X S1r

  lower=9751Testing软件测试网,|R(\!VrO

  else51Testing软件测试网A B-P&|A8H-}&p o

  upper=57

3V[Z4c#Iu7q0

  lower=48

y q5o8w)L4I0

  end if51Testing软件测试网5_(~A'O7T

  strnewpass=strnewpass & chr(int((upper-lower+1)*rnd)+lower)

[p n P c8|Iq0

  next51Testing软件测试网,sY|5Ze(E`P

  make_randomize=strnewpass51Testing软件测试网!GO|y\6U

  end function

.z\oSv s#zM0

  '生成安全码的图片。

3{&`1j-KG*L5s0

  random_num=make_randomize(4,1) ''生成4位数字的安全码

vE^:^^tH+w:{O.V0

  session("random_num")=random_num '为么调用session,没有session的安全码是完全没有意义的。呵呵 .

g X4ILO%J3\~b)]1w5A0

  Set Jpeg = Server.CreateObject("Persits.Jpeg") '调用组件51Testing软件测试网0RRmp dI

  Jpeg.Open Server.MapPath("t.jpg") '打开准备的图片

%k UiCSM Jm"p UD0

  Jpeg.Canvas.Font.Color = &HFFFFFF

vn+}N$Q@!J|:L0

  Jpeg.Canvas.Font.Family = "Arial Black"

Q6Bzs3@F U`0

  Jpeg.Canvas.Font.Bold = false

yF ^!qS8YZ|Z j0

  Jpeg.Canvas.PrintText 0, -2, random_num

T#lzx7y,nI0

  jpeg.save Server.MapPath("tt.jpg") '保存51Testing软件测试网*ci|"eJB.rO

  %>

@ E!S2p2DY{&hU-T0

  <img src="tt.jpg" border="0" align="absmiddle">51Testing软件测试网#h@i3g]t;q

  12、如何让AspJpeg组件支援数据库?51Testing软件测试网3e&b7B^Dg

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

5xT{0X{se0

  Opening Images from Memory

J0^'_6o'v0

  <% ' Using ADO, open database with an image blob51Testing软件测试网$i,e'S-b8}

  strConnect = "DRIVER={Microsoft Access Driver (*.mdb)};DBQ=" & Server.MapPath("../db/aspjpeg.mdb")

0t;F0M2y%P OEH0

  Set rs = Server.CreateObject("adodb.recordset")51Testing软件测试网$E_9c YT0N\}

  SQL = "select image_blob from images2 where id = " & Request("id")51Testing软件测试网%{_8rPp s{:{

  rs.Open SQL, strConnect, 1, 3

N9zt"Md yB!m:X/W4~0

  Set Jpeg = Server.CreateObject("Persits.Jpeg")51Testing软件测试网 @'Mo+c-P@X

  ' Open image directly from recordset51Testing软件测试网zA.P[![KB

  Jpeg.OpenBinary rs("image_blob").Value51Testing软件测试网$Nm+y;]5H:`7`

  ' Resize

]XR_s"z0

  jpeg.Width = Request("Width")

};`G1~vw&g0

  ' Set new height, preserve original aspect ratio

nEj#^ [0f!~"_0

  jpeg.Height = jpeg.OriginalHeight * jpeg.Width / jpeg.OriginalWidth51Testing软件测试网pzW&[$q O

  Jpeg.SendBinary51Testing软件测试网7N0J1iu,~[-y e

  rs.Close

Ff0M8oc2aoN7l4@0

  %>

ZP'X Krq2uEu#w0

  Output to Memory51Testing软件测试网 X S#U9Kp_j_

  <%

$[3C+zqx#pT0

  ...51Testing软件测试网Dz [ |0t

  Set rs = Server.CreateObject("adodb.recordset")51Testing软件测试网:m\|I"D'k%j

  rs.Open "images", strConnect, 1, 3

/gOxT.Y1uC,E.@0

  rs.AddNew

B.ktH\ ~0

  rs("image_blob").Value = Jpeg.Binary51Testing软件测试网-Db0EZbXt K3a

  rs.Update

7y"y6KK/k G$m0

  ...

$[P"}-s$aR0`l0`0

  %>51Testing软件测试网v0y~/e q7H0j"j9?

  更多方法介绍:

U#w"a g@7n kx0

  Canvas.Line(Left, Top, Right, Bottom)51Testing软件测试网4t H].aw9_r

  画一条直线

.S^3Dzb'E0

  Canvas.Ellipse(Left, Top, Right, Bottom)

Z6h OU1wm5r0

  画出一个椭圆51Testing软件测试网+LL7k B:E3ko

  Canvas.Circle(X, Y, Radius)51Testing软件测试网wT _-Q O

  画出一个圆

3LLyA { f|0

  Canvas.Bar(Left, Top, Right, Bottom)

,lT-H_C'{#q^0

  画出一个长方形,上面有代码介绍了

H']~F^rwtu0

  Canvas.Font.ShadowColor

:\Y-OQj&Pt0

  文字阴影颜色

\0vwE{}v0

  Canvas.Font.ShadowXOffset As Long51Testing软件测试网 I8Uq l r2?$J(_

  阴影X坐标设定51Testing软件测试网'w(F O3u2^Bt@"C

  Canvas.Font.ShadowYOffset As Long

r){R S0tJ0

  Y坐标设定51Testing软件测试网"`\)JM`

  Canvas.Font.BkMode As String51Testing软件测试网 L0|:B'G3j:\

  文字背景

vs0jN9wI4o$t#X0

TAG:

 

评分:0

我来说两句

Open Toolbar