Text Formatted Code
if ($_CONF_ADVT['$autothumbnail'] == 1 )
{
function makeThumb( $scrFile, $dstFile, $dstW=120, $dstH=100 )
{
global $_CONF;
$im = ImageCreateFromJPEG( $scrFile );
$srcW = ImageSX( $im );
$srcH = ImageSY( $im );
$ratio = ($srcW / $srcH);
$newW = $dstW;
$newH= round(($dstW / $ratio));
$ni = ImageCreateTrueColor( $newW, $newH );
ImageCopyResized( $ni, $im, 0, 0, 0, 0, $newW, $newH, $srcW, $srcH );
ImageJPEG( $ni, $dstFile );
}
}
You would notice that I didn't use the $dstH in the calculation even though I left it in there in case I want to limit the height in the future.
The New Width ($newW) is taken from the set width ($dstW=120, you can change it to any number you want). The New Height is calculated by dividing the $dstW by the $ratio that was obtained from the origional photo ($srcW / $srcH), to prevent distortion.