最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

php動態(tài)生成縮略圖并輸出顯示的方法

 更新時間:2015年04月20日 09:07:29   作者:不吃皮蛋  
這篇文章主要介紹了php動態(tài)生成縮略圖并輸出顯示的方法,涉及php操作圖片的相關(guān)技巧,非常具有實(shí)用價值,需要的朋友可以參考下

本文實(shí)例講述了php動態(tài)生成縮略圖并輸出顯示的方法。分享給大家供大家參考。具體如下:

調(diào)用方法:

<img src="thumbs.php?filename=photo.jpg&width=100&height=100">

此代碼可以為大圖片動態(tài)生成縮略圖顯示,圖片在內(nèi)存中生成,不在硬盤生成真實(shí)文件

thumbs.php文件如下:

<?php
$filename= $_GET['filename'];
$width = $_GET['width'];
$height = $_GET['height'];
$path="http://localhost/images/"; //finish in "/"
// Content type
header('Content-type: image/jpeg');
// Get new dimensions
list($width_orig, $height_orig) = getimagesize($path.$filename);
if ($width && ($width_orig < $height_orig)) {
  $width = ($height / $height_orig) * $width_orig;
} else {
  $height = ($width / $width_orig) * $height_orig;
}
// Resample
$image_p = imagecreatetruecolor($width, $height);
$image = imagecreatefromjpeg($path.$filename);
imagecopyresampled($image_p,$image,0,0,0,0,$width,$height,$width_orig,$height_orig);
// Output
imagejpeg($image_p, null, 100);
// Imagedestroy
imagedestroy ($image_p);
?>

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

相關(guān)文章

最新評論

平潭县| 西畴县| 广宗县| 房产| 莫力| 夏津县| 博罗县| 青神县| 台中县| 漳浦县| 桃园市| 儋州市| 武汉市| 合山市| 独山县| 湄潭县| 邵阳市| 原平市| 涡阳县| 蓬安县| 红原县| 湖州市| 阜新市| 湖南省| 淮南市| 南皮县| 屏南县| 鄂托克旗| 盱眙县| 庐江县| 怀仁县| 华阴市| 那坡县| 北票市| 布尔津县| 焦作市| 双峰县| 射阳县| 奉化市| 陕西省| 大田县|