002 |
if ( ! function_exists( 'ImageResize' )) |
006 |
function ImageResize($srcFile,$toW,$toH,$toFile= "" ) |
010 |
global $cfg_photo_type; |
022 |
$srcInfo = GetImageSize($srcFile,$info); |
030 |
if (!$cfg_photo_type[ 'gif' ]) |
038 |
$im = imagecreatefromgif($srcFile); |
044 |
if (!$cfg_photo_type[ 'jpeg' ]) |
052 |
$im = imagecreatefromjpeg($srcFile); |
058 |
if (!$cfg_photo_type[ 'png' ]) |
066 |
$im = imagecreatefrompng($srcFile); |
072 |
if (!$cfg_photo_type[ 'bmp' ]) |
080 |
$im = imagecreatefromwbmp($srcFile); |
090 |
if ($srcW<=$toW && $srcH<=$toH ) |
100 |
$newW = $toH * $srcW / $srcH; |
102 |
$newH = $toW * $srcH / $srcW; |
124 |
if ($srcW>$toW||$srcH>$toH) |
128 |
if (function_exists( "imagecreatetruecolor" )) |
132 |
@$ni = imagecreatetruecolor($ftoW,$ftoH); |
138 |
imagecopyresampled($ni,$im,0,0,0,0,$ftoW,$ftoH,$srcW,$srcH); |
146 |
$ni=imagecreate($ftoW,$ftoH); |
148 |
imagecopyresized($ni,$im,0,0,0,0,$ftoW,$ftoH,$srcW,$srcH); |
158 |
$ni=imagecreate($ftoW,$ftoH); |
160 |
imagecopyresized($ni,$im,0,0,0,0,$ftoW,$ftoH,$srcW,$srcH); |
166 |
$new_imgx = imagecreatetruecolor($toW,$toH); |
172 |
imagecopyresampled($new_imgx,$ni,0,0,0,($newH - $toH)/2,$toW,$toH,$toW,$toH); |
180 |
imagecopyresampled($new_imgx,$ni,0,0,($newW - $toW)/2,0,$toW,$toH,$toW,$toH); |
190 |
imagegif($new_imgx,$toFile); |
196 |
imagejpeg($new_imgx,$toFile,85); |
202 |
imagepng($new_imgx,$toFile); |
208 |
imagebmp($new_imgx,$toFile); |
218 |
imagedestroy($new_imgx); |
|