激情久久久_欧美视频区_成人av免费_不卡视频一二三区_欧美精品在欧美一区二区少妇_欧美一区二区三区的

服務器之家:專注于服務器技術及軟件下載分享
分類導航

PHP教程|ASP.NET教程|Java教程|ASP教程|編程技術|正則表達式|C/C++|IOS|C#|Swift|Android|VB|R語言|JavaScript|易語言|vb.net|

服務器之家 - 編程語言 - ASP教程 - ASPJPEG綜合操作的CLASS類

ASPJPEG綜合操作的CLASS類

2019-10-08 09:46asp教程網 ASP教程

ASPJPEG綜合操作的CLASS類

  1. <%   
  2. 'ASPJPEG綜合操作CLASS   
  3. Class AspJpeg   
  4. Dim AspJpeg_Obj,obj   
  5. Private Img_MathPath_From,Img_MathPath_To,Img_Reduce_Size,CoverIf   
  6. Private Img_Frame_Size,Img_Frame_Color,Img_Frame_Solid,Img_Frame_Width,Img_Frame_Height   
  7. Private Img_Font_Content,Img_Font_Family,Img_Font_Color,Img_Font_Quality,Img_Font_Size,Img_Font_Bold,Img_Font_X,Img_Font_Y   
  8. Private Img_PicIn_Path,Img_PicIn_X,Img_PicIn_Y   
  9. '--------------取原文件路徑   
  10. Public Property Let MathPathFrom(StrType)   
  11. Img_MathPath_From=StrType   
  12. End Property   
  13.  
  14. '--------------取文件保存路徑   
  15. Public Property Let MathPathTo(strType)   
  16. Img_MathPath_To=strType   
  17. End Property   
  18.  
  19. '--------------保存文件時是否覆蓋已有文件   
  20. Public Property Let CovePro(LngSize)   
  21. If LngSize=0 or LngSize=1 or LngSize=true or LngSize=false then   
  22. CoverIf=LngSize   
  23. End If   
  24. End Property   
  25.  
  26. '---------------取縮略圖/放大圖 縮略值   
  27. Public Property Let ReduceSize(LngSize)   
  28. If isNumeric(LngSize) then   
  29. Img_Reduce_Size=LngSize   
  30. End If   
  31. End Property   
  32.  
  33. '---------------取描邊屬性   
  34. '邊框粗細   
  35. Public Property Let FrameSize(LngSize)   
  36. If isNumeric(LngSize) then   
  37. Img_Frame_Size=Clng(LngSize)   
  38. End If   
  39. End Property   
  40. '邊框寬度   
  41. Public Property Let FrameWidth(LngSize)   
  42. If isNumeric(LngSize) then   
  43. Img_Frame_Width=Clng(LngSize)   
  44. End If   
  45. End Property   
  46. '邊框高度   
  47. Public Property Let FrameHeight(LngSize)   
  48. If isNumeric(LngSize) then   
  49. Img_Frame_Height=Clng(LngSize)   
  50. End If   
  51. End Property   
  52. '邊框顏色   
  53. Public Property Let FrameColor(strType)   
  54. If strType<>"" then   
  55. Img_Frame_Color=strType   
  56. End If   
  57. End Property   
  58. '邊框是否加粗   
  59. Public Property Let FrameSolid(LngSize)   
  60. If LngSize=1 or LngSize=0 or LngSize=true or LngSize=false then   
  61. Img_Frame_Solid=LngSize   
  62. End If   
  63. End Property   
  64.  
  65. '---------------取插入文字屬性   
  66. '插入的文字   
  67. Public Property Let Content(strType)   
  68. If strType<>"" then   
  69. Img_Font_Content=strType   
  70. End If   
  71. End Property   
  72. '文字字體   
  73. Public Property Let FontFamily(strType)   
  74. If strType<>"" then   
  75. Img_Font_Family=strType   
  76. End If   
  77. End Property   
  78. '文字顏色   
  79. Public Property Let FontColor(strType)   
  80. If strType<>"" then   
  81. Img_Font_Color=strType   
  82. End If   
  83. End Property   
  84. '文字品質   
  85. Public Property Let FontQuality(LngSize)   
  86. If isNumeric(LngSize) then   
  87. Img_Font_Quality=Clng(LngSize)   
  88. End If   
  89. End Property   
  90. '文字大小   
  91. Public Property Let FontSize(LngSize)   
  92. If isNumeric(LngSize) then   
  93. Img_Font_Size=Clng(LngSize)   
  94. End If   
  95. End Property   
  96. '文字是否加粗   
  97. Public Property Let FontBold(LngSize)   
  98. If LngSize=1 or LngSize=0 or LngSize=true or LngSize=false then   
  99. Img_Font_Bold=LngSize   
  100. End If   
  101. End Property   
  102. '輸入文字的X坐標   
  103. Public Property Let FontX(LngSize)   
  104. If isNumeric(LngSize) then   
  105. Img_Font_X=Clng(LngSize)   
  106. End If   
  107. End Property   
  108. '輸入文字的Y坐標   
  109. Public Property Let FontY(LngSize)   
  110. If isNumeric(LngSize) then   
  111. Img_Font_Y=Clng(LngSize)   
  112. End If   
  113. End Property   
  114.  
  115. '---------------取插入圖片屬性   
  116. '插入圖片的路徑   
  117. Public Property Let PicInPath(strType)   
  118. Img_PicIn_Path=strType   
  119. End Property   
  120. '圖片插入的X坐標   
  121. Public Property Let PicInX(LngSize)   
  122. If isNumeric(LngSize) then   
  123. Img_PicIn_X=Clng(LngSize)   
  124. End If   
  125. End Property   
  126. '圖片插入的Y坐標   
  127. Public Property Let PicInY(LngSize)   
  128. If isNumeric(LngSize) then   
  129. Img_PicIn_Y=Clng(LngSize)   
  130. End If   
  131. End Property   
  132.  
  133.  
  134. Private Sub Class_Initialize()   
  135. Set AspJpeg_Obj=createObject("Persits.Jpeg")   
  136. Img_MathPath_From=""   
  137. Img_MathPath_To=""   
  138. Img_Reduce_Size=150   
  139. Img_Frame_Size=1   
  140. 'Img_Frame_Width=0   
  141. 'Img_Frame_Height=0   
  142. 'Img_Frame_Color="&H000000"   
  143. 'Img_Frame_Bold=false   
  144. Img_Font_Content="GoldenLeaf"   
  145. 'Img_Font_Family="Arial"   
  146. 'Img_Font_Color="&H000000"   
  147. Img_Font_Quality=3   
  148. Img_Font_Size=14   
  149. 'Img_Font_Bold=False   
  150. Img_Font_X=10   
  151. Img_Font_Y=5   
  152. 'Img_PicIn_X=0   
  153. 'Img_PicIn_Y=0   
  154. CoverIf=1   
  155.  
  156. End Sub   
  157. Private Sub Class_Terminate()   
  158. Err.Clear   
  159. Set AspJpeg_Obj=Nothing   
  160. End Sub   
  161. '判斷文件是否存在   
  162. Private Function FileIs(path)   
  163. Set fsos=Server.createObject("Scripting.FileSystemObject")   
  164. FileIs=fsos.FileExists(path)   
  165. Set fsos=Nothing   
  166. End Function   
  167.  
  168. '判斷目錄是否存在   
  169. Private Function FolderIs(path)   
  170. Set fsos=Server.createObject("Scripting.FileSystemObject")   
  171. FolderIs=fsos.FolderExists(path)   
  172. Set fsos=Nothing   
  173. End Function   
  174. '*******************************************   
  175. '函數作用:取得當前文件的上一級路徑   
  176. '*******************************************   
  177. Private Function UpDir(ByVal D)   
  178. If Len(D) = 0 then   
  179. UpDir=""   
  180. Else   
  181. UpDir=Left(D,InStrRev(D,"\")-1)   
  182. End If   
  183. End Function   
  184.  
  185. Private Function Errors(Errors_id)   
  186. select Case Errors_id   
  187. Case "0"   
  188. Errors="指定文件不存在"   
  189. Case 1   
  190. Errors="指定目錄不存在"   
  191. Case 2   
  192. Errors="已存在相同名稱文件"   
  193. Case 3   
  194. Errors="參數溢出"   
  195. End select   
  196. End Function   
  197.  
  198.  
  199. '取圖片寬度   
  200. Public Function ImgInfo_Width(Img_MathPath)   
  201. If Not(FileIs(Img_MathPath)) then   
  202. 'Exit Function   
  203. ImgInfo_Width=Errors(0)   
  204. Else   
  205. AspJpeg_Obj.Open Img_MathPath   
  206. ImgInfo_Width=AspJpeg_Obj.width   
  207. End If   
  208. End Function   
  209. '取圖片高度   
  210. Public Function ImgInfo_Height(Img_MathPath)   
  211. If Not(FileIs(Img_MathPath)) then   
  212. 'Exit Function   
  213. ImgInfo_Height=Errors(0)   
  214. Else   
  215. AspJpeg_Obj.Open Img_MathPath   
  216. ImgInfo_Height=AspJpeg_Obj.height   
  217. End If   
  218. End Function   
  219. '生成縮略圖/放大圖   
  220. Public Function Img_Reduce()   
  221. If Not(FileIs(Img_MathPath_From)) then   
  222. Img_Reduce=Errors(0)   
  223. Exit Function   
  224. End If   
  225. If Not(FolderIs(UpDir(Img_MathPath_To))) then   
  226. Img_Reduce=Errors(1)   
  227. Exit Function   
  228. End If   
  229. If CoverIf=0 or CoverIf=False then   
  230. If FileIs(Img_MathPath_To) then   
  231. Img_Reduce=Errors(2)   
  232. Exit Function   
  233. End If   
  234. End If   
  235. AspJpeg_Obj.Open Img_MathPath_From   
  236. AspJpeg_Obj.PreserveAspectRatio = True   
  237. If AspJpeg_Obj.OriginalWidth>AspJpeg_Obj.OriginalHeight Then   
  238. AspJpeg_Obj.Width=Img_Reduce_Size   
  239. Else   
  240. AspJpeg_Obj.Height=Img_Reduce_Size   
  241. End If   
  242. If AspJpeg_Obj.OriginalWidth>Img_Reduce_Size or AspJpeg_Obj.OriginalHeight>Img_Reduce_Size Then   
  243. If AspJpeg_Obj.Width<Img_Reduce_Size or AspJpeg_Obj.Height<Img_Reduce_Size then   
  244. Set AspJpeg_Obj_New=createObject("Persits.Jpeg")   
  245. AspJpeg_Obj_New.new Img_Reduce_Size,Img_Reduce_Size,&HFFFFFF   
  246. AspJpeg_Obj_New.DrawImage (150-AspJpeg_Obj.width)/2,(150-AspJpeg_Obj.height)/2,AspJpeg_Obj   
  247. If Img_Frame_Size>0 then   
  248. Call Img_Pen(AspJpeg_Obj_New)   
  249. End If   
  250. If Img_Font_Content<>"" then   
  251. Img_Font_X=AspJpeg_Obj_New.Width/2   
  252. Img_Font_Y=AspJpeg_Obj_New.Height-15   
  253. Call Img_Font(AspJpeg_Obj_New)   
  254. End If   
  255. AspJpeg_Obj_New.Sharpen 1, 130   
  256. AspJpeg_Obj_New.Save Img_MathPath_To   
  257. Set AspJpeg_Obj_New=Nothing   
  258. Else   
  259. If Img_Frame_Size>0 then   
  260. Call Img_Pen(AspJpeg_Obj)   
  261. End If   
  262. If Img_Font_Content<>"" then   
  263. Img_Font_X=AspJpeg_Obj.Width/2   
  264. Img_Font_Y=AspJpeg_Obj.Height-15   
  265. Call Img_Font(AspJpeg_Obj)   
  266. End If   
  267. AspJpeg_Obj.Sharpen 1, 130   
  268. AspJpeg_Obj.Save Img_MathPath_To   
  269. End If   
  270. Else   
  271. If Img_Frame_Size>0 then   
  272. Call Img_Pen(AspJpeg_Obj)   
  273. End If   
  274. If Img_Font_Content<>"" then   
  275. Img_Font_X=AspJpeg_Obj.Width/2   
  276. Img_Font_Y=AspJpeg_Obj.Height-15   
  277. Call Img_Font(AspJpeg_Obj)   
  278. End If   
  279. AspJpeg_Obj.Sharpen 1, 130   
  280. AspJpeg_Obj.Save Img_MathPath_To   
  281. End If   
  282. End Function   
  283. '生成水印   
  284. Public Function Img_WaterMark()   
  285. If Not(FileIs(Img_MathPath_From)) then   
  286. Img_WaterMark=Errors(0)   
  287. Exit Function   
  288. End If   
  289. If Img_MathPath_To="" then   
  290. Img_MathPath_To=Img_MathPath_From   
  291. ElseIf Not(FolderIs(UpDir(Img_MathPath_To))) then   
  292. Img_WaterMark=Errors(1)   
  293. Exit Function   
  294. End If   
  295. If CoverIf=0 or CoverIf=false then   
  296. If Img_MathPath_To<>Img_MathPath_From and FileIs(Img_MathPath_To) then   
  297. Img_WaterMark=Errors(2)   
  298. Exit Function   
  299. End If   
  300. End If   
  301. AspJpeg_Obj.Open Img_MathPath_From   
  302. If Img_PicIn_Path<>"" then   
  303. If Not(FileIs(Img_PicIn_Path)) then   
  304. Img_WaterMark=Errors(0)   
  305. Exit Function   
  306. End If   
  307. Set AspJpeg_Obj_New=createObject("Persits.Jpeg")   
  308. AspJpeg_Obj_New.Open Img_PicIn_Path   
  309. AspJpeg_Obj.PreserveAspectRatio = True   
  310. AspJpeg_Obj_New.PreserveAspectRatio = True   
  311. If AspJpeg_Obj.OriginalWidth<Img_Reduce_Size or AspJpeg_Obj.OriginalHeight<Img_Reduce_Size then   
  312. Img_WaterMark=Errors(3)   
  313. Exit Function   
  314. End If   
  315. If AspJpeg_Obj_New.OriginalWidth>AspJpeg_Obj_New.OriginalHeight Then   
  316. AspJpeg_Obj_New.Width=Img_Reduce_Size   
  317. Else   
  318. AspJpeg_Obj_New.Height=Img_Reduce_Size   
  319. End If   
  320. If Img_PicIn_X="" then Img_PicIn_X=AspJpeg_Obj.Width-AspJpeg_Obj_New.Width   
  321. If Img_PicIn_Y="" then Img_PicIn_Y=AspJpeg_Obj.Height-AspJpeg_Obj_New.Height   
  322. AspJpeg_Obj.DrawImage Img_PicIn_X,Img_PicIn_Y,AspJpeg_Obj_New   
  323. Set AspJpeg_Obj_New=Nothing   
  324. End If   
  325. If Img_Frame_Size>0 then   
  326. Call Img_Pen(AspJpeg_Obj)   
  327. End If   
  328. If Img_Font_Content<>"" then   
  329. Call Img_Font(AspJpeg_Obj)   
  330. End If   
  331. 'AspJpeg_Obj.Sharpen 1, 130   
  332. AspJpeg_Obj.Save Img_MathPath_To   
  333. End Function   
  334. '生成框架   
  335. Private Function Img_Pen(Obj)   
  336. If Img_Frame_Width=0 then Img_Frame_Width=Obj.Width   
  337. If Img_Frame_Height=0 then Img_Frame_Height=Obj.Height   
  338. Obj.Canvas.Pen.Color = Img_Frame_Color   
  339. Obj.Canvas.Pen.Width = Img_Frame_Size   
  340. Obj.Canvas.Brush.Solid = Img_Frame_Solid   
  341. Obj.Canvas.Bar 1,1,Img_Frame_Width,Img_Frame_Height   
  342. End Function   
  343. '生成水印字   
  344. Private Function Img_Font(Obj)   
  345. Obj.Canvas.Font.Color = Img_Font_Color   
  346. Obj.Canvas.Font.Family = Img_Font_Family   
  347. Obj.Canvas.Font.Quality=Img_Font_Quality   
  348. Obj.Canvas.Font.Size=Img_Font_Size   
  349. Obj.Canvas.Font.Bold = Img_Font_Bold   
  350. Obj.Canvas.Print Img_Font_X,Img_Font_Y,Img_Font_Content   
  351. End Function   
  352. End Class   
  353. %>   


這個類可以公開調用  
1. ImgInfo_Height 取圖片高度  
2. ImgInfo_Width 取圖片寬度  
調用方法:  

復制代碼代碼如下:


Dim NewObj,Pic_h,Pic_w   
Set NewObj=New AspJpeg   
Pic_h=NewObj.ImgInfo_Height("f:/test.jpg")   
Pic_w=NewObj.ImgInfo_Width("f:/test.jpg")   
Set NewObj=Nothing   
Response.Write "This Picture's Height is "&Pic_h   
Response.Write "This Picture's Width is "&Pic_w   
Response.End  


3. Img_Reduce 對指定圖片縮小或放大并保存(可選擇是否加水印,是否加框架)  
必須定義聲明 MathPathFrom,MathPathTo  
默認為縮放至150X150 圖案 如按比例縮放后圖案小于該尺寸,則補充空白圖片  
默認文件自動覆蓋  
實例: 

復制代碼代碼如下:


Dim NewObj,NewCommand   
Set NewObj=New AspJpeg   
NewObj.MathPathFrom="f:/test.jpg"   
NewObj.MathPathTo="f:/reduce.jpg"   
NewCommand=NewObj.Img_Reduce   
Set NewObj=Nothing   
If NewCommand<>"" then   
Response.Write "Success"   
Else   
'圖片操作過程中出現錯誤   
Response.Write "Failed"   
End If  


4. Img_WaterMark 給指定圖片添加水印  
水印可以為圖片 文字 或 2者結合 

延伸 · 閱讀

精彩推薦
主站蜘蛛池模板: 欧美日韩一 | 国产精品一区二区三区在线播放 | 91短视频版高清在线观看www | 黄色国产在线观看 | 免费毛片随便看 | 国产精品午夜小视频观看 | 羞羞网站视频 | 久久久免费观看完整版 | 色人阁导航| 羞羞的动漫在线观看 | va免费视频 | av免费在线观看国产 | 久久久成人免费视频 | 日本欧美在线播放 | 精品二区在线观看 | 国产一区视频在线免费观看 | wwwcom国产 | 欧美成人一级片 | 调教小男生抽打尿孔嗯啊视频 | 国产羞羞视频在线观看免费应用 | 成人国产视频在线观看 | 亚洲成人精品在线 | 久久成人黄色 | 亚洲一区 国产精品 | av国产免费 | 牛牛碰在线 | 亚洲成人播放 | 一级免费毛片 | 999久久久精品| 亚洲va在线 | 欧美黄色一级片在线观看 | 毛片免费视频 | 免费特黄 | 视频一区免费观看 | 91美女视频在线 | chinese18 xxxx videos| 色视频一区二区 | 日韩男人的天堂 | 欧美一级片在线 | 国产精品一 | 羞羞视频免费观看入口 |