How to calculate java BufferedImage filesize

后端 未结 6 1512
闹比i
闹比i 2021-01-04 04:41

I have a servlet based application that is serving images from files stored locally. I have added logic that will allow the application to load the image file to a Buffered

6条回答
  •  灰色年华
    2021-01-04 05:06

    No, you must write the file in memory or to a temporary file.

    The reason is that it's impossible to predict how the JPEG encoding will affect file size.

    Also, it's not good enough to "guess" at the file size; the Content-Length header has to be spot-on.

提交回复
热议问题