ImagePack is a very useful python module to pack and distribute icon images. ImagePack base64 encodes and packs all icon images into a python module called ImageUNpack. You can than distribute your code including ImageUNpack without having to provide the actual icon files. It is particularly handy if you freeze your python code with py2exe or pyInstaller and want to freeze everything in one file. This way you can distribute a single file and create the icon files from within your code by calling ImageUNpack.
The best part about ImagePack is that it packs all icons by itself and stores the relative paths. You dont have to worry about file names, icon directories or the actual encoding. Run ImagePack to encode your icons. Run the created ImageUNpack when you need the actual icon files. This creates all icon files and folders relative the the ImageUNpack execution directory.
Image pack base64 encodes any image from its root folder down the directory tree. It stores its name and its relative path in regards to ImagePack execution directory. The output of ImagePack is a python module named ImageUNpack.py.
To base64 decode your icon images simply run ImageUNpack in the desired location. It will create the icon files in their according relative folders in regards to ImageUNpack.
in the desired directory. The output is ImageUNpack.To exclude image icon files, add a list of all folders in the function pack([‘folder1′,’folder2′]) at the bottom of ImagePack.py.
To unpack your images run
in your code. This will create all original icon files and its relative folders.
ImagePack has the option to exclude directories. Simply pass a list of strings including the folder names you want excluded to ImagePack.pack.
tested on 2.6, but should work 2.5 and higher.
Python modules required
GNU GENERAL PUBLIC LICENSE, feel free to use and share it. If you do use ImagePack please give me credit somewhere in blog or in the Readme file. Ty.