Ian if perfectly correct, now all you have to do is calculate the table size itself - BEFORE sending any output - so that you know what to resize the image to. That is why I said 'with difficulty'. Though 'with complexity' would be more accurate - especially as different browsers will render the table slightly differently as well. And of course the user's screen resolution, default font size and window size will all impact on the calculation.
I take it that the border image is designed to scale without significant distortion or fuzziness - it should be. If so, then just use CSS and let the browser do the work. You will want to put themj all in a div with 'display: block' and remove margins and padding to eliminate gaps, then just let the browser auto-resize for you.