Hey guys.
The default image format TI uses doesn't have any compression, which results in very slow loadings and big file size. I've written a small library which allows to compress images or data on your computer and decompress it in Lua on the calculator.
Decompressing in Lua might seem a bit overkill but it actually works out quite nicely, and I've experienced substantial gains in loading speed and file size.
Currently, only two algorithms are supported : RLE (Run-length encoding) and LZW (Lempel-Ziv-Welch). RLE tends to produce lighter files, but they also tend to load slower than those produced by LZW.
The library is located in src/compress.lua. You can use packages lzw.py, rle.py, lua.py and image.py to compress your data or your images. The convert.py utility allows for fast conversion between any image format to lua or tns files. Examples of use can be found below.
The image.py package requires ImageMagick to be installed on your computer and the 'convert' and 'identify' utilities to be in your PATH.
In order to produce tns files, the convert.py package requires luna to be installed on your computer and the 'luna' executable to be in your PATH.
Version 0.0.4 :https://mega.co.nz/#!owxVXbAQ!MPb4JRfuZbVcEriqC6IqsUbJRjdcQw9CMYDzvEuwahcChangelog: http://ourl.ca/19010/351502 Version 0.0.3 :https://mega.co.nz/#!UxYBAZQR!BfvEC079-PEB0j98wG58RGjTjJRrt4GDA5xsJMV1KYYChangelog:
http://ourl.ca/19010/350707Version 0.0.2 :https://mega.co.nz/#!w8hTnIJB!SDoEbCshxMgHZbV3bNXFcxCMy-0d9H3iK7fUiFTpoZ8Changelog :
- image.py now uses ImageMagick instead of PIL. It's a bit slower, but should produce a better output and it allows more control on the output. As a consequence, it now requires ImageMagick to be installed on your system and the 'convert' and 'identify' utilities to be in your PATH.
- example.py renamed to convert.py, now takes command line arguments to allow automatic generation of lua or tns files. TNS file generation requires luna to be installed on your system and to be in your PATH.
- lzw.decompress and rle.decompress (lua) now take a table as an optional third argument. It allows to prepend a header directly onto the output instead of concatenating strings.
Examples :
Display help message
python convert.py -h
Converts every image in img/ to lua files in lua/
python convert.py img/* -o lua/
Converts every png and gif image in img/ to tns files in the same directory, restricted to a palette of 128 colors (default is 256)
python convert.py --tns -c 128 img/*.png img/*.gif
If your path selector targets non image file, an error will be thrown.
Example :
python convert.py passwords.txt
Traceback (most recent call last):
File "convert.py", line 23, in <module>
image = Image(path, colors=args.colors)
File "/Users/alexandre/Projets/compress/image.py", line 17, in __init__
raise Exception(stderr_output)
Exception: identify: no decode delegate for this image format `passwords.txt' @ error/constitute.c/ReadImage/550.
Version 0.0.1 :https://mega.co.nz/#!UwhnDRAJ!Tuad9XC01kTMPOZRa7DztkY7okJrhJ7NgMElQwSm8GQThe library is located in src/compress.lua. You can use packages lzw.py, rle.py, lua.py and image.py to compress your data or your images. Examples can be found in example.py and src/example.lua.
The image.py package requires the PIL to be installed on your computer. If you already have Python 2.7.3/3.X, you can install it via "pip install pillow".