$ftoW=$toH;
[size=; font-size: inherit,inherit] $ftoH=$toH;
///
[size=; font-size: inherit,inherit] if( $srcH<=$toH && $srcW<=$toW )
[size=; font-size: inherit,inherit] {
[size=; font-size: inherit,inherit] $ftoW=$srcW;
[size=; font-size: inherit,inherit] $ftoH=$srcH;
[size=; font-size: inherit,inherit] if(function_exists("imagecreatetruecolor"))
[size=; font-size: inherit,inherit] {
[size=; font-size: inherit,inherit] @$ni = imagecreatetruecolor($ftoW,$ftoH);
[size=; font-size: inherit,inherit] if($ni)
[size=; font-size: inherit,inherit] {
[size=; font-size: inherit,inherit] imagecopyresampled($ni,$im,0,0,0,0,$ftoW,$ftoH,$srcW,$srcH);
[size=; font-size: inherit,inherit] }
[size=; font-size: inherit,inherit] else
[size=; font-size: inherit,inherit] {
[size=; font-size: inherit,inherit] $ni=imagecreate($ftoW,$ftoH);
[size=; font-size: inherit,inherit] imagecopyresized($ni,$im,0,0,0,0,$ftoW,$ftoH,$srcW,$srcH);
[size=; font-size: inherit,inherit] }
[size=; font-size: inherit,inherit] }
[size=; font-size: inherit,inherit] else
[size=; font-size: inherit,inherit] {
[size=; font-size: inherit,inherit] $ni=imagecreate($ftoW,$ftoH);
[size=; font-size: inherit,inherit] imagecopyresized($ni,$im,0,0,0,0,$ftoW,$ftoH,$srcW,$srcH);
[size=; font-size: inherit,inherit] }
[size=; font-size: inherit,inherit] switch ($srcInfo[2])
[size=; font-size: inherit,inherit] {
[size=; font-size: inherit,inherit] case 1:
[size=; font-size: inherit,inherit] imagegif($ni,$toFile);
[size=; font-size: inherit,inherit] break;
[size=; font-size: inherit,inherit] case 2:
[size=; font-size: inherit,inherit] imagejpeg($ni,$toFile,100);
[size=; font-size: inherit,inherit] break;
[size=; font-size: inherit,inherit] case 3:
[size=; font-size: inherit,inherit] imagepng($ni,$toFile);
[size=; font-size: inherit,inherit] break;
[size=; font-size: inherit,inherit] case 6:
[size=; font-size: inherit,inherit] imagebmp($ni,$toFile);
[size=; font-size: inherit,inherit] break;
[size=; font-size: inherit,inherit] default:
[size=; font-size: inherit,inherit] return false;
[size=; font-size: inherit,inherit] }
[size=; font-size: inherit,inherit] imagedestroy($ni);
[size=; font-size: inherit,inherit] } ///
$toWH=$toW/$toH;
$srcWH=$srcW/$srcH;
if($toWH<=$srcWH)
{
$ftoW=$toW;
$ftoH=$ftoW*($srcH/$srcW);
}
else
{
$ftoH=$toH;
$ftoW=$ftoH*($srcW/$srcH);
}
|