php生成圖片縮略圖的方法
更新時間:2015年04月07日 11:58:49 作者:不吃皮蛋
這篇文章主要介紹了php生成圖片縮略圖的方法,涉及php操作圖片的技巧,非常具有實用價值,需要的朋友可以參考下
本文實例講述了php生成圖片縮略圖的方法。分享給大家供大家參考。具體如下:
這里需要用到GD2 library
function make_thumb($src,$dest,$desired_width) { /* read the source image */ $source_image = imagecreatefromjpeg($src); $width = imagesx($source_image); $height = imagesy($source_image); /* find the "desired height" of this thumbnail, relative to the desired width */ $desired_height = floor($height*($desired_width/$width)); /* create a new, "virtual" image */ $virtual_image = imagecreatetruecolor($desired_width,$desired_height); /* copy source image at a resized size */ imagecopyresized($virtual_image,$source_image,0,0,0,0,$desired_width,$desired_height,$width,$height); /* create the physical thumbnail image to its destination */ imagejpeg($virtual_image,$dest, 83); }
希望本文所述對大家的php程序設(shè)計有所幫助。
您可能感興趣的文章:
相關(guān)文章
php獲取服務(wù)器端mac和客戶端mac的地址支持WIN/LINUX
這篇文章主要介紹了php獲取服務(wù)器端mac和客戶端mac地址的方法,需要的朋友可以參考下2014-05-05php+MySql實現(xiàn)登錄系統(tǒng)與輸出瀏覽者信息功能
這篇文章主要介紹了php+MySql實現(xiàn)登錄系統(tǒng)與輸出瀏覽者信息功能 的相關(guān)資料,需要的朋友可以參考下2016-07-07將酷狗krc歌詞解析并轉(zhuǎn)換為lrc歌詞php源碼
這篇文章主要介紹了krc歌詞解析并轉(zhuǎn)換為lrc歌詞的php實現(xiàn)方法,需要的朋友可以參考下2014-06-06php將access數(shù)據(jù)庫轉(zhuǎn)換到mysql數(shù)據(jù)庫的方法
這篇文章主要介紹了php將access數(shù)據(jù)庫轉(zhuǎn)換到mysql數(shù)據(jù)庫的方法,可實現(xiàn)讀取access數(shù)據(jù)庫數(shù)據(jù)并寫入到mysql數(shù)據(jù)庫中,具有一定的參考借鑒價值,需要的朋友可以參考下2014-12-12