Image compression methods of Android Luban and compressor

1. Luban compression problem https://github.com/Curzibn/Luban

Previously, I selected the compressed image library. I found the most star on GitHub. The method is to pass in the image array and call back the returned results in the asynchronous thread. Next, there is a problem. The quality of the compressed image is blurred. Although you can set the number of KB not to compress, there is no big problem with the compression of the normal mobile phone screen. But on the tablet, the same picture will be blurred by compression.

2,Compressor https://github.com/zetbaitsu/Compressor

This compression is a time-consuming operation in the main thread. You need to write an asynchronous thread and pass messages to the main thread through the handler.

. setmaxwidth (640). Setmaxheight (480) the higher the two values, the smaller the compression force and the picture is not clear,

. setquality (75) this method only sets the image quality and does not affect the size of the compressed image

. setcompressformat (bitmap. Compressformat. Webp) webp image format is launched by Google. It has strong compression and high quality, but IOS does not recognize it. It is necessary to convert the image into byte stream and then PNG format

. setcompressformat (bitmap. Compressformat. PNG) compression in PNG format will cause the picture to become larger, consume too much memory and slow response of the mobile phone

. setcompressformat (bitmap. Compressformat. JPEG) JPEG compression; The compression speed is faster than PNG, the quality is general, and basically belongs to the compression ratio of 1 / 10

Here, judge whether the size of paths is equal to the size of the image array, and judge whether to call the handler to pass messages to the main thread for other operations

The above is the whole content of this article. I hope it will be helpful to your study, and I hope you can support programming tips.

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>