GithubHelp home page GithubHelp logo

recallmenot / 6zip_micro_compressor Goto Github PK

View Code? Open in Web Editor NEW
0.0 1.0 0.0 33 KB

compress files & images for storage on embedded devices (packbits, uzlib, heatshrink)

License: MIT License

Makefile 3.27% C 88.38% Shell 8.36%

6zip_micro_compressor's Introduction

6zip micro compressor

This program serves to store compressed 1-bit-per-pixel images / generic files on a micro controller, in compressed form.

There are 3 algorithms to choose from:

  • the skirridsystems implementation of the packbits run-length (de)compression algorithm. largest compressed size, smallest code space use for decompression.
  • the pfalcon radically debloated implementation of the DEFLATE (dictionary + huffman trees) (de)compression algorithm named (uzlib), there are two flavors:
    • uzlibfull, which produces a file with compression header and trailer (CRC, length of contents)
    • uzlibraw, which has the header and trailer stripped away (smaller size)
  • the atomicobject heatshrink LZSS (dictionary + breakeven) compression algorithm for embedded devices with very limited RAM

install

git clone https://github.com/recallmenot/uc_image_compressor.git
cd uc_image_compressor
git clone https://github.com/skirridsystems/packbits.git
git clone https://github.com/pfalcon/uzlib.git
git clone https://github.com/atomicobject/heatshrink.git
make

conversion

running ./compressor --help will show usage instructions.
tests.sh offers an extensive collection of examples.

For organisatory purposes it is heavily reccomended you keep the compressed files in these file extensions:

  • .packed for bitpacked files
  • .uzf for uzlibfull compressed files
  • .uzr for uzlibraw compressed files
  • .heatshrunk for heatshrink compressed files

compressing images

  1. Use an image editing tool like pinta, paint.net or GIMP to turn your image into the right size (e.g. 32 x 32 pixels) and convert it to monochrome (black and white). We want a 1 bit per pixel image in the right size (multiple of 8 pixels). Save it as a TIFF or BMP (lossless).
  2. for images that belong together, you may want to stack them vertically before compression. This may result in greater compression with the dictionary-based algorithms. Use imagemagick convert -append 1.tiff 2.tiff 3.tiff out.tiff
  3. Use imagemagick to convert the image to the pbm format convert -monochrome image.tiff image.pbm
  4. strip the remaining pbm header and compress using ./compressor --image --compress
  5. convert the packed data to an array in a .h file xxd -i image.[ext] > image.h, where [ext] is one of the compressed extensions above

The resulting .h file can be #included in your C / C++ project.

xxd will not declare the array const, you may want to do this in the resulting .h file so the compiler will definitely write it to FLASH.

decompressing images

All 4 "formats" can also be decompressed, this will restore pbm headers but requires you to specify width and height.

compressing files

You can compress files, they will be compressed in full (no headers are stripped)

decompressing files

You can decompress files, no headers will be added.

6zip_micro_compressor's People

Contributors

recallmenot avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.