https://static.06ms.com/static/images/index/3.jpg

PHP缩略图类

<?php
/**
* @author www.iklfy.com
* @copyright 2011
* @filename thumb.class.php
*/
$arrFile = array('p1.jpg', 'p2.gif', 'p4.txt', 'p3.png');
/**
* 得到等比例缩放的长宽
*/
function getNewSize($maxWidth, $maxHeight, $srcWidth, $srcHeight)
{
if ($srcWidth < $srcHeight)
{
$maxWidth = ($maxHeight / $srcHeight) * $srcWidth;
}
else
{
$maxHeight = ($maxWidth / $srcWidth) * $srcHeight;
}
return array('width' => $maxWidth, 'height' => $maxHeight);
}