Skip to content
Snippets Groups Projects
Commit dd7bbbf4 authored by Andreas Gohr's avatar Andreas Gohr
Browse files

cleanups in resize_imageGD (maybe #631)

darcs-hash:20051203133713-7ad00-6c4d3126fb5de8e5396c214b1f6c82f99eca98ae.gz
parent ccdfa6c0
No related branches found
No related tags found
No related merge requests found
......@@ -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;
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment