开发者

how to reduce the size of file....in java [duplicate]

开发者 https://www.devze.com 2023-02-24 17:06 出处:网络
This question already has answers here: Closed 11 years ago. Possible Duplicate: Resize an image in Java - Any Open Source Library ?
This question already has answers here: Closed 11 years ago.

Possible Duplicate:

Resize an image in Java - Any Open Source Library ?

InputStream is = new FileInputStream(file)开发者_开发百科;
    long length = file.length();
    // if (length > Integer.MAX_VALUE) {
    // File is too large
    // }
    byte[] bytes = new byte[(int) length];

if i enter large image....it should accept but size should be reduced


  • Image resize in Java
  • Java Image Manupulation


First, you should use a buffer and read the data in buffer-size increments, otherwise you will probably have problems when the data is big.

Second, as suggested by other users, you should use compression, or, since we are talking about images, you can always downsample it as a last resource, if you are in a very memory constrained environment.

0

精彩评论

暂无评论...
验证码 换一张
取 消