php生成圖片縮略圖的方法_PHP教程
教程Tag:暫無Tag,歡迎添加,賺取U幣!
推薦:php獲取網頁里所有圖片并存入數組的方法本文實例講述了php獲取網頁里所有圖片并存入數組的方法。分享給大家供大家參考。具體如下: 希望本文所述對大家的php程序設計有所幫助。
這篇文章主要介紹了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加密解密函數Authcode()修復版代碼Authcode這個函數很多人都使用,這函數來自Discuz程序,用于加密解密字符串,可以設置鑰匙(key)和過期時間,在很多時候都用得著。原版的函數代碼可能會生成+、/、這樣的字符,導致通過URL傳值取回時被轉義,導致無法解密。火端網絡稍加修改,把這幾個字符替換成其它
相關PHP教程:
- 相關鏈接:
- 教程說明:
PHP教程-php生成圖片縮略圖的方法。