diff --git a/html/inc/util.inc b/html/inc/util.inc index 63c605833e..253736cd77 100644 --- a/html/inc/util.inc +++ b/html/inc/util.inc @@ -489,68 +489,6 @@ function close_output_buffer($filename) { } -function intelligently_scale_image($sourcefile, $fw, $fh) -{ - - //In order to use the default built-in GD library all imageCreateTrueColor - //has been commented out. - //If you whish to enable the advanced GD features (resamples copy for instance) - //simply switch back to the commented functions. - -list($ow, $oh, $from_type) = getimagesize($sourcefile); - -switch($from_type) -{ -case 1: // GIF -$srcImage = imageCreateFromGif($sourcefile); -break; -case 2: // JPG -$srcImage = imageCreateFromJpeg($sourcefile); -break; -case 3: // PNG -$srcImage = imageCreateFromPng($sourcefile); -break; -} - -$tempw = $fw; -$temph = number_format((($oh*$fw)/$ow), 0); - -if($temph < $fh) -{ -$tempw = number_format((($ow*$fh)/$oh), 0); -$temph = $fh; -} - -//$tempImage = imageCreateTrueColor($tempw, $temph); -//imageAntiAlias($tempImage, true); -$tempImage = imageCreate($tempw, $temph); - -//imagecopyresampled($tempImage, $srcImage, 0, 0, 0, 0, $tempw, $temph, $ow, $oh); -imagecopyresized($tempImage, $srcImage, 0, 0, 0, 0, $tempw, $temph, $ow, $oh); - - -// Calculate offsets -if($temph > $fh) -{ -$offsety = number_format(($temph/2)-($fh/2), 0); -$offsetx = 0; -} -else -{ -$offsety = 0; -$offsetx = number_format(($tempw/2)-($fw/2), 0); -} - -//$destImage = imageCreateTrueColor($fw, $fh); -//imagecopyresampled($destImage, $tempImage, 0, 0, $offsetx, $offsety, $fw, $fh, $fw, $fh); - -$destImage = imageCreate($fw, $fh); -imagecopyresized($destImage, $tempImage, 0, 0, $offsetx, $offsety, $fw, $fh, $fw, $fh); - -return $destImage; //imageJpeg($destImage, $destfile, $jpegquality); - -} - function intelligently_scale_image($sourcefile, $fw, $fh) { //In order to use the default built-in GD library all imageCreateTrueColor @@ -589,7 +527,7 @@ function intelligently_scale_image($sourcefile, $fw, $fh) { // Calculate offsets - if($temph $fh) { + if($temph < $fh) { $offsety = number_format(($temph/2)-($fh/2), 0); $offsetx = 0; } else {