AspJpeg介绍

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

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

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

  AspJpeg可以使用很少的代码在您的ASP/ASP.Net应用程序上动态的创建高质量的缩略图象,支持的图象格式有:JPEG, GIF, BMP, TIFF, PNG。

}D T,W/DM+NXL7`o0

  AspJpeg主要可以做到:生成缩略图片、生成水印图片、图片合并、图片切割、数据库支持、安全码技术51Testing软件测试网 _0y)ZDoq yF*|

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

%ifC3W`Z'W+i0

  安装SN:09268-26217-40710

u:TVv5i-p)~0

  2、AspJpeg功能摘要51Testing软件测试网rg!['sM

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

UF^\T7W+Q$~|0

  源图片可以来源于磁盘、内存、或者记录集(数据库)51Testing软件测试网:Rm9d"{C{S

  缩略图片可以保存到磁盘、内存、或者HTTP流

bXU*H6]@I0

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

f,vxx4Iq0

  可以在图片之上添加图片或者文字.

&F j+v reVdv?7Jv0

  支持画中画

'r jO/U\J#x0

  支持复制,反转,旋转,锐化,灰度调节.51Testing软件测试网``zG-IctEl

  可以调节压缩比率,以得到最佳输出效果和大小.

!u;n1Q R6V0

  从Jpeg图片中抽取EXIF 和 IPTC数据.51Testing软件测试网q B @.J!j2{2E

  CMYK-RGB转换51Testing软件测试网 yJ^4d}jM

  Read/write access to individual pixels of an image. (从图象中对任意象素进行读/写存取。)51Testing软件测试网M%H"TYh a Y7y4fXa._']

  3、AspJpeg系统需求

v&k6V0v0Q&jaj/m0

  Windows 95/98/NT/2000/XP/2003, and51Testing软件测试网` HqAh

  IIS 4.0+ and ASP/ASP.NET, or

(m3x'Z x&_3Y uYu0

  Visual Basic 5.0+, or51Testing软件测试网xIU;D4D9N+D K$T rM

  Visual C++ 5.0+, or51Testing软件测试网8w1r+Qd9Ka[2l

  any development environment supporting COM.51Testing软件测试网 g3ou1\"tW8h:wI

  4、AspJpeg安装

9sR9Ey_h nB0?0

  全新安装:

_ a B4CT B"r0

  在AspJpeg安装过程中输入序列号即可,如果安装位置磁盘格式为NTFS,则可能出现访问权限问题,需手工设置安装目录对Everyone有访问权限。51Testing软件测试网{.{t+P"zOr8fq0F0b/S

  更新安装:51Testing软件测试网Dx:UB8|,d

  如果之前有装过其它版本的AspJpeg组件,则需要先卸载原来的组件,再进行新版本的安装。51Testing软件测试网4|6j(F/@,h4ngpS

  先停止IIS51Testing软件测试网 MNOG\^d

  Net Stop iisadmin /y

dP |-xW;i^ l S0

  卸载旧版组件51Testing软件测试网 E G_l'S t

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

;c[4a`7nP5e a0

  重启IIS51Testing软件测试网AR-Ld/db5GL4g

  Net Start w3svc51Testing软件测试网W(Ne3Z/TS

  然后再进行全新安装或复制AspJpeg.dll文件到安装目录进行手工安装:51Testing软件测试网)F(_ \ ?@~%DV)i

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

v~ y0W D0

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

  Windows Registry Editor Version 5.0051Testing软件测试网@.E0S q%^2S0f/f t

  [HKEY_LOCAL_MACHINE\SOFTWARE\Persits Software\AspUpload3\RegKey]51Testing软件测试网pI/R4HOs3E:ch

  @="21764-40765-60456"

P)RD2u(U3|`0

  5、如何创建一个AspJpeg实例?51Testing软件测试网5j rT~K

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

ZfW*rh6X%ZLtFm0

  6、如何查看到期时间(是否注册成功)?51Testing软件测试网kwE,j;p^9X

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

{w:qZ w#n*I*o6?5DZ%_(V0

  Response.Write Jpeg.Expires

dv!_tBL9fz@0

  注册成功则到期时间为:9999-9-951Testing软件测试网(g9Gr-r} _$xti^

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

2c1ph w{/|K0

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

#ghY {9K|+q7jY0

  <%51Testing软件测试网{Z(N#\&l[?6B

  Set Jpeg = Server.CreateObject("Persits.Jpeg") '创建实例51Testing软件测试网E$V^+eU9]q

  Path = Server.MapPath("../images/apple.jpg") '处理图片路径51Testing软件测试网,n3}!f(AmE+@L

  Jpeg.Open Path '打开图片51Testing软件测试网3RS[*`!Rr9_8V

  '调整宽度和高度为原来的50%51Testing软件测试网 ],h(Z8g r)L

  Jpeg.Width = Jpeg.OriginalWidth / 251Testing软件测试网{kl8Y@)U

  Jpeg.Height = Jpeg.OriginalHeight / 2

Xl/l:{#Ww;xcm:K0

  Jpeg.Save Server.MapPath("apple_small.jpg") '保存图片到磁盘51Testing软件测试网 {5`B-? D@2ML

  Jpeg.Close:Set Jpeg = Nothing51Testing软件测试网Q%y0O9t \*pp%^;k[QN

  %>51Testing软件测试网 u_.wn(g*I$Xt

  8、如何用AspJpeg组件生成图片水印?51Testing软件测试网NLD)b_e|

  <%

ZR)p*ad8v\1S:h0

  Set Jpeg = Server.CreateObject("Persits.Jpeg")51Testing软件测试网,Y4Ry-X.U.i:`

  Jpeg.Open Server.MapPath("images/dodge_viper.jpg")51Testing软件测试网;|n2Jr|e S)m9j C

  开始写文字51Testing软件测试网fg/De8K,o

  Jpeg.Canvas.Font.Color = &000000'' red 颜色

wt,Bo%Fj0

  Jpeg.Canvas.Font.Family = "Courier New" 字体51Testing软件测试网6l aZ;QNov OL2w+?

  Jpeg.Canvas.Font.Bold = True 是否加粗51Testing软件测试网 rq @A`d\;x6V$l

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

B:oX(z4d0

  打印坐标x 打印坐标y 需要打印的字符

(oB%P#H)l4co0

  以下是对图片进行边框处理51Testing软件测试网bW7ne?y*~xg

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

q;M)yzafi0

  Jpeg.Canvas.Pen.Width = 2 画笔宽度51Testing软件测试网mb9s4O rX

  Jpeg.Canvas.Brush.Solid = False 是否加粗处理51Testing软件测试网I~~ _.V h*c

  Jpeg.Canvas.Bar left, top, right, bottom ' 左,上,右,下51Testing软件测试网q3b9G!G(_Z)_S6A d

  Jpeg.Save Server.MapPath("images/dodge_viper_framed.jpg") 保存

!W3@x"Uu0

  %>

Gjj'x|1S0

  9、如何用AspJpeg组件进行图片合并?51Testing软件测试网0nU2Wa.}Bcu

  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):

Xee(Em_P0

  使用该方法,您必需创建两个AspJpeg实例对象51Testing软件测试网kJd2T6Sm6?Q }3i6`

  <%

3pRA'|L)p^&Y0

  Set Jpeg1 = Server.CreateObject("Persits.Jpeg")51Testing软件测试网 D5C3? EB

  Set Jpeg2 = Server.CreateObject("Persits.Jpeg")51Testing软件测试网e({+BVV h

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

0wgqT!F~ l"n0

  Jpeg2.Open Server.MapPath("t1.jpg")51Testing软件测试网t'jR)Q*MC'n&eM"y

  Jpeg1.Canvas.DrawImage 10, 10, Jpeg2 ' optional arguments omitted51Testing软件测试网aud|2jP8U

  jpeg1.save Server.mappath("tt.jpg")51Testing软件测试网$B!vr9sx"O j

  %>51Testing软件测试网V _4vz0@

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

+S1T"zQ7EA_G0

  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软件测试网Z.L)K2vA

  <%51Testing软件测试网$yHc%E | j7KW,\

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

pQ(L.T3m q9z_kV0

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

M8S VPg'`7R+r0

  jpeg.Crop 20, 30, jpeg.Width - 20, jpeg.Height - 1051Testing软件测试网(t-Et,B9{0H

  jpeg.save Server.mappath("tt.jpg")51Testing软件测试网7jp1mbl6Z

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

ME+| e{9}U!C0

  %>

Wr"|1I+@ h7i0

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

qQ*j6U#i.B:L.y8P#L6?0

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

e ^z.xusE3O0

  <%

d"C;d%{a+P0

  function make_randomize(max_len,w_n) 'max_len 生成长度,w_n:0 可能包含字母,1:只为数字51Testing软件测试网0K!dZ k3Q6~uS$k&H

  randomize51Testing软件测试网HTC]Q0` nm F(F

  for intcounter=1 to max_len51Testing软件测试网/nC6Q(}.||:[UK

  whatnext=int((1-0+1)*rnd+w_n)

Z RDL{4u4`0

  if whatnext=0 then

(F"Y(w%joT0

  upper=122

1p`zT*[ gn%M6{0

  lower=97

8u*YYy&XTP0

  else

ozS Df)O"US k0

  upper=5751Testing软件测试网%Z x%BX n

  lower=48

2X uW1qNqTYx?0

  end if

5dR1L1l0D`(\0

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

V[.V T0C d {+l Y0

  next51Testing软件测试网,B9wRom jat0ma

  make_randomize=strnewpass51Testing软件测试网]eiSr1r*W k2OD,h

  end function

z)pD `%asu@0

  '生成安全码的图片。51Testing软件测试网6] ePX8n;~2gxNu{

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

*A-j]} k7r#e.J e%J @9I0

  session("random_num")=random_num '为么调用session,没有session的安全码是完全没有意义的。呵呵 .51Testing软件测试网!f(ZX,W/| k'l-U ]{8S

  Set Jpeg = Server.CreateObject("Persits.Jpeg") '调用组件51Testing软件测试网+D Jz*ZU-Oo

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

$`nR!Pd4x-or0

  Jpeg.Canvas.Font.Color = &HFFFFFF

%WqF },ylk5]5D/Q0

  Jpeg.Canvas.Font.Family = "Arial Black"51Testing软件测试网:DV2UZqT#s A ` Ln

  Jpeg.Canvas.Font.Bold = false51Testing软件测试网wg SBu$Q+i @

  Jpeg.Canvas.PrintText 0, -2, random_num51Testing软件测试网 ssNt/?/~.B Im `m

  jpeg.save Server.MapPath("tt.jpg") '保存51Testing软件测试网,~r W!M(S

  %>51Testing软件测试网8^ SDR;nQ/a;M*J

  <img src="tt.jpg" border="0" align="absmiddle">51Testing软件测试网W$?+D ]/T8~mR|

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

Jz,_r3v-m6Y{0

  图片存进数据库只能以二进制数据保存,这里即利用AspJpeg的Binary方法,下面以两个AspJpeg用户手册上的代码为例,具体请参考AspJpeg用户手册:51Testing软件测试网"?tTp5R:~rC

  Opening Images from Memory51Testing软件测试网Yn%S[3kz)c5W(R N3u

  <% ' Using ADO, open database with an image blob

o l4S8R#@mf0

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

] rnY!P[ x.h{l/U0

  Set rs = Server.CreateObject("adodb.recordset")51Testing软件测试网7[$mz.t Ks)Im

  SQL = "select image_blob from images2 where id = " & Request("id")

IR*H4d[#Z_9n"dJ0

  rs.Open SQL, strConnect, 1, 3

2};e g{/K3o0y2]0

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

Vp)ni5K2n Muj0

  ' Open image directly from recordset51Testing软件测试网b${.sMI!zMIx$c

  Jpeg.OpenBinary rs("image_blob").Value

2K!f*?6B6fy0

  ' Resize

_EeD\]5t0

  jpeg.Width = Request("Width")51Testing软件测试网Z9~7qqa9q5^

  ' Set new height, preserve original aspect ratio51Testing软件测试网+Q-sh Pd$uWV

  jpeg.Height = jpeg.OriginalHeight * jpeg.Width / jpeg.OriginalWidth

L.`;v(Ig"IS5a {9G[0

  Jpeg.SendBinary51Testing软件测试网?.aZHi!D

  rs.Close

E/Q-U-p9L9sAdM0

  %>51Testing软件测试网h{deM

  Output to Memory

1`6@MS5q:R h@'H0

  <%51Testing软件测试网0?n2H XT

  ...

Y P F%m(\#h0

  Set rs = Server.CreateObject("adodb.recordset")

3H vZ;|7u6{ n.X!U] ^"c4i0

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

Pl UK?,K m0

  rs.AddNew51Testing软件测试网 p6I:b bg1] O

  rs("image_blob").Value = Jpeg.Binary51Testing软件测试网}M1Dx+F QR L(v5K

  rs.Update51Testing软件测试网yT8]!IzWH1K

  ...

8H)\)JD:N-r {,OZ |0

  %>51Testing软件测试网4Q d Y_4I?'C jvwe

  更多方法介绍:

1]gbB8s;E R0

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

(O)hZ/C9aD0

  画一条直线51Testing软件测试网/vRn7Hx1e j)Vu

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

~*M3W\%y0

  画出一个椭圆

M0fC0bz1d7o%e0

  Canvas.Circle(X, Y, Radius)51Testing软件测试网PX9~;Vx_] kW

  画出一个圆51Testing软件测试网"Z-|7@4|^} aO%l

  Canvas.Bar(Left, Top, Right, Bottom)51Testing软件测试网`4I;Xqh5\ o)p_:f~

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

v"v7Y`g fLS$r0

  Canvas.Font.ShadowColor51Testing软件测试网y,o0s$gK5D

  文字阴影颜色

wATQw/U4f0

  Canvas.Font.ShadowXOffset As Long

&]7eVm DXm0

  阴影X坐标设定51Testing软件测试网d ^&W;]@:t9]

  Canvas.Font.ShadowYOffset As Long

"[(xRRHu"Cd0

  Y坐标设定51Testing软件测试网7ou!A/t/t5Y u3l-i N

  Canvas.Font.BkMode As String51Testing软件测试网"hbV [$bxy

  文字背景

{)kn9i u Gv.a0

TAG:

 

评分:0

我来说两句

Open Toolbar