1){ $op="bcdiv"; $dimension="w"; $odimension="h"; } else{ $op="bcmul"; $dimension="h"; $odimension="w"; } $imgRatio=($imgDet[0]/$imgDet[1]); $newMeasure[$dimension]=$measure; $newMeasure[$odimension]=round($op($measure,$imgRatio,5)); $imgOut = imagecreatetruecolor($newMeasure['w'], $newMeasure['h']); imagecopyresized($imgOut, $srcImg, 0, 0, 0, 0, $newMeasure['w'], $newMeasure['h'], $imgDet[0], $imgDet[1]); } else $imgOut=$srcImg; // Output header(sprintf("'Content-type: %s'",$imgDet['mime']));// Content type imagejpeg($imgOut);//image ?>