国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 開發 > PHP > 正文

php生成圖片縮略圖的方法

2024-05-04 23:33:58
字體:
來源:轉載
供稿:網友

這篇文章主要介紹了php生成圖片縮略圖的方法,涉及php操作圖片的技巧,非常具有實用價值,需要的朋友可以參考下

本文實例講述了php生成圖片縮略圖的方法。分享給大家供大家參考。具體如下:

這里需要用到GD2 library

 

 
  1. function make_thumb($src,$dest,$desired_width
  2.  
  3. /* read the source image */ 
  4. $source_image = imagecreatefromjpeg($src); 
  5. $width = imagesx($source_image); 
  6. $height = imagesy($source_image); 
  7. /* find the "desired height" of this thumbnail, relative to the desired width */ 
  8. $desired_height = floor($height*($desired_width/$width)); 
  9. /* create a new, "virtual" image */ 
  10. $virtual_image = imagecreatetruecolor($desired_width,$desired_height); 
  11. /* copy source image at a resized size */ 
  12. imagecopyresized($virtual_image,$source_image,0,0,0,0,$desired_width,$desired_height,$width,$height); 
  13. /* create the physical thumbnail image to its destination */ 
  14. imagejpeg($virtual_image,$dest, 83); 

希望本文所述對大家的php程序設計有所幫助。

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 尖扎县| 宜城市| 天津市| 咸丰县| 隆回县| 荔波县| 申扎县| 景东| 体育| 壤塘县| 寻乌县| 城市| 峨眉山市| 文成县| 莎车县| 威海市| 白朗县| 海林市| 遂昌县| 会昌县| 鄢陵县| 浏阳市| 莱州市| 郴州市| 山西省| 曲阳县| 榆社县| 泾源县| 同仁县| 濮阳市| 如东县| 清徐县| 邹城市| 桓仁| 孝感市| 阳春市| 贡嘎县| 巴塘县| 四川省| 天门市| 镶黄旗|