$sh * $maxw) { //width must fit $dw = $maxw; $dh = $dw * $sh / $sw; } else { //height must fit $dh = $maxh; $dw = $dh * $sw / $sh; } break; case 'distort': $dw = $maxw; $dh = $maxh; break; default: trigger_error("UNKNOWN IMAGE RESIZE STYLE [$imgstyle]"); break; } if (($dw > $sw) && ($dh > $sh)) { //don't grow, just shrink, so return what i have return $imagedata; } $im2 = imagecreatetruecolor($dw, $dh); imagecopyresampled($im2, $im, 0, 0, 0, 0, $dw, $dh, $sw, $sh); ob_start(); imagejpeg($im2, '', param('image resize quality')); imagedestroy($im2); $imagedata = ob_get_contents(); ob_end_clean(); imagedestroy($im); } else { trigger_error('RESIZE IMAGE RECEIVED A NON-IMAGE PARAMETER'); } return $imagedata; } ?>