简体   繁体   中英

Resize a bitmap eficiently and without losing quality in android

I want to reduce the size of an image on disk without losing quality. I don't want to change the width and height of original image.

I want to do something like https://tinyjpg.com/

It reduces the size of image without changing the width and height of image.

You need to compress with jpeg, if you want to reduce size without change measurements. Try this;

String file = ...
OutputStream s = new FileOutputStream(file);
BitmapFactory.decodeFile(file).compress(CompressFormat.JPEG, 80, s);
s.close();

80 is compression factor which between 0-100 (0 lowest quality, 100 highest quality). Try to find best for your situation.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM