How to calculate java BufferedImage filesize

后端 未结 6 1511
闹比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 04:47

    Before you load the image file as a BufferedImage make a reference to the image file via the File object.

    File imgObj = new File("your Image file path");
    int imgLength = (int) imgObj.length();
    

    imgLength would be your approximate image size though it my vary after resizing and then any operations you perform on it.

提交回复
热议问题