進階
asp中測試
<%
'產生縮減
On Error resume next
set obj=server.CreateObject("flysoft.image")
obj.LoadFromFile=server.MapPath("./love.bmp") '原始圖片
obj.Rate =0.5 '縮放比率 其中<1為縮小,>1為放大
obj.OutputImgFile server.MapPath("./lovethumbmail_bmp.jpg") '產生結果圖片
if err.number<>0 then
response.write Err.Description
end if
%>
'產生浮水印
<%
'產生文字浮水印
On Error resume next
set obj=server.CreateObject("flysoft.image")
obj.Rate = 0.5 '縮放比率 其中<1為縮小,>1為放大
obj.MarkRotate = 25 '旋轉角度
obj.MaskText = "浪漫的情人節 祝天下有情人終成眷屬" '要顯示的文字
obj.MaskTextFontName = "華文彩雲" '字型設定
obj.LoadFromFile =server.MapPath("./rose.bmp") '原始圖片
obj.OutputTxtImgFile server.MapPath("./rose_txtimg.jpg") , vbBlack, 20, 50, 0, 400 '參數分別代表:產生的圖片,字型的顏色,字型的寬度,字型的高度,最後兩個參數指文字相對於原始圖片左上方的座標位置
if err.number<>0 then
response.write Err.Description
end if
%>
<%
'產生圖片浮水印
On Error resume next
set obj=server.CreateObject("flysoft.image")
obj.Rate = 0.5 '縮放比率 其中<1為縮小,>1為放大
obj.LoadFromFile = server.MapPath("./love.JPG") '原始圖片
obj.LoadFromMaskImgFile = server.MapPath("./rose_mark.bmp") '浮水印圖片
obj.OutputMarkImgFile server.MapPath("./lovemark.jpg"), 350, 350, 100 '產生結果圖片 500,500為浮水印圖片相對於原始圖片左上方的座標位置 最後的100是透明度 (0最透明,100不透明)
if err.number<>0 then
response.write Err.Description
end if
%>
同時還作了效能測試
作者的機器配置是賽揚850,記憶體512機器上產生50張圖片(縮減,文字浮水印,圖片浮水印)用了7秒
機器配置是p4 2.4,記憶體1G 機器上產生50張圖片(縮減,文字浮水印,圖片浮水印)用了2秒