No worries, worked it out.
@imagecopyresampled($thumb, $im, 0, 0, 0, 0, $imgw, $imgh, $height, $width);
Should've been
@imagecopyresampled($thumb, $im, 0, 0, 0, 0, $imgw, $imgh, $width), $height;
Just went for a walk and nailed it soon as I got back. Yeah!