ller resulting image dimension if both height
        // and width are set and $constrain is also set
        $hx = (100 / ($sw / $w)) * .01;
        $hx = @round ($sh * $hx);

        $wx = (100 / ($sh / $h)) * .01;
        $wx = @round ($sw * $wx);

        if ($hx &lt; $h) {
                $h = (100 / ($sw / $w)) * .01;
                $h = @round ($sh * $h);
        } else {
                $w = (100 / ($sh / $h)) * .01;
                $w = @round ($sw * $w);
        }
}


$im = @ImageCreateFromJPEG (