diff options
author | Andreas Gohr <andi@splitbrain.org> | 2005-12-03 14:37:13 +0100 |
---|---|---|
committer | Andreas Gohr <andi@splitbrain.org> | 2005-12-03 14:37:13 +0100 |
commit | dd7bbbf4ad5dd98d77769170867a5ab4e198b565 (patch) | |
tree | 6406750aa35adffbd4a81d3786b31940b36bb72c /lib/exe/fetch.php | |
parent | ccdfa6c0da3891892f92fb99a28e684bfc592569 (diff) | |
download | rpg-dd7bbbf4ad5dd98d77769170867a5ab4e198b565.tar.gz rpg-dd7bbbf4ad5dd98d77769170867a5ab4e198b565.tar.bz2 |
cleanups in resize_imageGD (maybe #631)
darcs-hash:20051203133713-7ad00-6c4d3126fb5de8e5396c214b1f6c82f99eca98ae.gz
Diffstat (limited to 'lib/exe/fetch.php')
-rw-r--r-- | lib/exe/fetch.php | 36 |
1 files changed, 25 insertions, 11 deletions
diff --git a/lib/exe/fetch.php b/lib/exe/fetch.php index 89c88090c..efca50f18 100644 --- a/lib/exe/fetch.php +++ b/lib/exe/fetch.php @@ -224,7 +224,10 @@ function resize_imageGD($ext,$from,$from_w,$from_h,$to,$to_w,$to_h){ $newimg = @imagecreatetruecolor ($to_w, $to_h); } if(!$newimg) $newimg = @imagecreate($to_w, $to_h); - if(!$newimg) return false; + if(!$newimg){ + imagedestroy($image); + return false; + } //keep png alpha channel if possible if($ext == 'png' && $conf['gdlib']>1 && function_exists('imagesavealpha')){ @@ -232,9 +235,6 @@ function resize_imageGD($ext,$from,$from_w,$from_h,$to,$to_w,$to_h){ imagesavealpha($newimg,true); } - // create cachedir - //io_makeFileDir($to); // not needed anymore, should exist - //try resampling first if(function_exists("imagecopyresampled")){ if(!@imagecopyresampled($newimg, $image, 0, 0, 0, 0, $to_w, $to_h, $from_w, $from_h)) { @@ -244,18 +244,32 @@ function resize_imageGD($ext,$from,$from_w,$from_h,$to,$to_w,$to_h){ imagecopyresized($newimg, $image, 0, 0, 0, 0, $to_w, $to_h, $from_w, $from_h); } + $okay = false; if ($ext == 'jpg' || $ext == 'jpeg'){ - if(!function_exists("imagejpeg")) return false; - return imagejpeg($newimg, $to, 70); + if(!function_exists('imagejpeg')){ + $okay = false; + }else{ + $okay = imagejpeg($newimg, $to, 70); + } }elseif($ext == 'png') { - if(!function_exists("imagepng")) return false; - return imagepng($newimg, $to); + if(!function_exists('imagepng')){ + $okay = false; + }else{ + $okay = imagepng($newimg, $to); + } }elseif($ext == 'gif') { - if(!function_exists("imagegif")) return false; - return imagegif($newimg, $to); + if(!function_exists('imagegif')){ + $okay = false; + }else{ + $okay = imagegif($newimg, $to); + } } - return false; + // destroy GD image ressources + if($image) imagedestroy($image); + if($newimg) imagedestroy($newimg); + + return $okay; } |