日期:2014-05-17 浏览次数:20509 次
<?php $sourceimage = '3.jpg'; $maxthumbWidth = 200; $maxthumbHeight = 800; $original = imagecreatefromjpeg($sourceimage); $dims = getimagesize($sourceimage); $a = $maxthumbWidth/$dims[0]; $b = $maxthumbHeight/$dims[1]; if($a<$b) { $thumbWidth = $maxthumbWidth; $thumbHeight = $dims[1]*$a; } else { $thumbWidth = $dims[0]*$b; $thumbHeight = $maxthumbHeight; } $thumb = imagecreatetruecolor($thumbWidth,$thumbHeight); imagecopyresampled($thumb,$original,0,0,0,0,$thumbWidth,$thumbHeight,$dims[0],$dims[1]); header("Content-type:image/jpeg"); imagejpeg($thumb); ?>