相關(guān)下載: AspJpeg破解版下載
1、如何創(chuàng )建一個(gè)AspJpeg實(shí)例?
Set Jpeg = Server.CreateObject("Persits.Jpeg")
2、如何查看到期時(shí)間(是否注冊成功)?
Set Jpeg = Server.CreateObject("Persits.Jpeg")
Response.Write Jpeg.Expires
注冊成功則到期時(shí)間為:9999-9-9
否則為:安裝日期加1個(gè)月期限
3、如何用AspJpeg組件生成圖片縮略圖?
<%
Set Jpeg = Server.CreateObject("Persits.Jpeg") '創(chuàng )建實(shí)例
Path = Server.MapPath("../images/apple.jpg") '處理圖片路徑
Jpeg.Open Path '打開(kāi)圖片
'調整寬度和高度為原來(lái)的50%
Jpeg.Width = Jpeg.OriginalWidth / 2
Jpeg.Height = Jpeg.OriginalHeight / 2
Jpeg.Save Server.MapPath("apple_small.jpg") '保存圖片到磁盤(pán)
Jpeg.Close:Set Jpeg = Nothing
%>
4、如何用AspJpeg組件生成圖片水???
<%
Set Jpeg = Server.CreateObject("Persits.Jpeg")
Jpeg.Open Server.MapPath("images/dodge_viper.jpg")
開(kāi)始寫(xiě)文字
Jpeg.Canvas.Font.Color = &000000'' red 顏色
Jpeg.Canvas.Font.Family = "Courier New" 字體
Jpeg.Canvas.Font.Bold = True 是否加粗
Jpeg.Canvas.Print 10, 10, "Copyright (c) XYZ, Inc."
打印坐標x 打印坐標y 需要打印的字符
以下是對圖片進(jìn)行邊框處理
Jpeg.Canvas.Pen.Color = &H000000'' black 顏色
Jpeg.Canvas.Pen.Width = 2 畫(huà)筆寬度
Jpeg.Canvas.Brush.Solid = False 是否加粗處理
Jpeg.Canvas.Bar 1, 1, Jpeg.Width, Jpeg.Height
起始X坐標 起始Y坐標 輸入長(cháng)度 輸入高度
Jpeg.Save Server.MapPath("images/dodge_viper_framed.jpg") 保存
%>
5、如何用AspJpeg組件進(jìn)行圖片合并?
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):
使用該方法,您必需創(chuàng )建兩個(gè)AspJpeg實(shí)例對象
<%
Set Jpeg1 = Server.CreateObject("Persits.Jpeg")
Set Jpeg2 = Server.CreateObject("Persits.Jpeg")
Jpeg1.Open Server.MapPath("t.jpg")
Jpeg2.Open Server.MapPath("t1.jpg")
Jpeg1.Canvas.DrawImage 10, 10, Jpeg2 ' optional arguments omitted
jpeg1.save Server.mappath("tt.jpg")
%>
本文來(lái)源:www.php18.com
6、如何用AspJpeg組件進(jìn)行圖片切割?
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 = Server.CreateObject("Persits.Jpeg")
Jpeg.Open Server.MapPath("t.jpg")
jpeg.Crop 20, 30, jpeg.Width - 20, jpeg.Height - 10
jpeg.save Server.mappath("tt.jpg")
Response.write("<img src=tt.jpg>")
%>
7、如何用AspJpeg組件創(chuàng )建安全碼?
創(chuàng )建安全碼原理上和創(chuàng )建水印差不多。
<%
function make_randomize(max_len,w_n) 'max_len 生成長(cháng)度,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,沒(méi)有session的安全碼是完全沒(méi)有意義的。呵呵 .
Set Jpeg = Server.CreateObject("Persits.Jpeg") '調用組件
Jpeg.Open Server.MapPath("t.jpg") '打開(kāi)準備的圖片
Jpeg.Canvas.Font.Color = &HFFFFFF
Jpeg.Canvas.Font.Family = "Arial Black"
Jpeg.Canvas.Font.Bold = false
Jpeg.Canvas.PrintText 0, -2, random_num
jpeg.save Server.MapPath("tt.jpg") '保存
%>
<img src="tt.jpg" border="0" align="absmiddle">
12、如何讓AspJpeg組件支援數據庫?
圖片存進(jìn)數據庫只能以二進(jìn)制數據保存,這里即利用AspJpeg的Binary方法,下面以?xún)蓚€(gè)AspJpeg用戶(hù)手冊上的代碼為例,具體請參考AspJpeg用戶(hù)手冊:
Opening Images from Memory
<% ' Using ADO, open database with an image blob
strConnect = "DRIVER={Microsoft Access Driver (*.mdb)};DBQ=" & Server.MapPath("../db/aspjpeg.mdb")
Set rs = Server.CreateObject("adodb.recordset")
SQL = "select image_blob from images2 where id = " & Request("id")
rs.Open SQL, strConnect, 1, 3
Set Jpeg = Server.CreateObject("Persits.Jpeg")
' Open image directly from recordset
Jpeg.OpenBinary rs("image_blob").Value
' Resize
jpeg.Width = Request("Width")
' Set new height, preserve original aspect ratio
jpeg.Height = jpeg.OriginalHeight * jpeg.Width / jpeg.OriginalWidth
Jpeg.SendBinary
rs.Close
%>
Output to Memory
<%
...
Set rs = Server.CreateObject("adodb.recordset")
rs.Open "images", strConnect, 1, 3
rs.AddNew
rs("image_blob").Value = Jpeg.Binary
rs.Update
...
%>
聯(lián)系客服