How to calculate java BufferedImage filesize

后端 未结 6 1494
闹比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:08

    Well, the BufferedImage doesn't know that it's being written as a JPEG - as far as it's concerned, it could be PNG or GIF or TGA or TIFF or BMP... and all of those have different file sizes. So I don't believe there's any way for the BufferedImage to give you a file size directly. You'll just have to write it out and count the bytes.

提交回复
热议问题