john04047210 / pyhuffman

基于huffman实现文件压缩,压缩部分采用c编写,编译生成python库,供python使用。项目中将普通图片二值化再按照bit记录每个像素的信息,基于此算法生成的文件再利用huffman压缩,大小可以进一步减小

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Install from source:

  • $ python setup.py build
  • $ python setup.py install

Usage:

  • compress & decompress:
    python example:
#-*- coding:utf-8 -*-
import PycHuffman as huffman


def run_test():
    file_in = 'original_file.jpg'
    file_out = 'compressed_file.hum.bin'
    file_out_out = 'decompressed_file.hum.jpg'
    rtn = huffman.compress(file_in, file_out)
    print('compress return:', rtn)
    rtn = huffman.decompress(file_out, file_out_out)
    print('decompress return:', rtn)
    


if __name__ == '__main__':
    run_test()

Upload PyPI

  • $ python -m pip install --user --upgrade setuptools wheel twine
  • $ python setup.py sdist bdist_wheel
  • $ python -m twine upload --repository-url https://upload.pypi.org/legacy/ dist/*

Upload TestPyPI

About

基于huffman实现文件压缩,压缩部分采用c编写,编译生成python库,供python使用。项目中将普通图片二值化再按照bit记录每个像素的信息,基于此算法生成的文件再利用huffman压缩,大小可以进一步减小

License:MIT License


Languages

Language:C 93.8%Language:Python 6.2%