Huffman algorithm is also a lossless compression algorithm, but unlike LZW compression algorithm, Huffman need to get a priori knowledge of the probability of each character appearing. By calculating the frequency of each character in a sequence of characters, a unique coding design is made for each character, so that the characters with high frequency have a short number of digits, and the frequency is low, to achieve the purpose of compression. Typically, you can save 20%~90% space and rely heavily on the characteristics of your data! Huffman encoding is a variable-length encoding, which means that the encoding length for each character is not unique.
Prefix code: The encoding of any one character is not a prefix of another character encoding in the same character set. Huffman encoding is the optimal prefix code, that is, the minimum amount of data after compression.
Project Link: Https://github.com/ewgcat/CompressImageByHuffman
Image compression using Libjpeg (Huffman algorithm, lossless compression)
How to use:
Method One, rely on compress
Method Two, copy example lib package file to your project, use reference example
Recommended method to download compress, according to the specific needs, repack
Attention
1, only support Armeabi;
2, the compression process is a time-consuming operation, must be called in the child thread
3, picture compression has the maximum limit, if you want to specify how many KB compression, use other compression methods.
Use effect
Lossless compression of 3.58M images to 100KB
Image compression using Libjpeg (Huffman algorithm, lossless compression)