Pure Python implemented Memory-mapped Frame Buffer mainly for GIF animation on Raspberry pi
Recent Raspberry pi and similar single-board computers which needs efficient way to show image usually uses fbi. This pack of C libraries and programs are able to show GIF image properly thorugh direct frame buffer, but in lack of function to play GIF animation files.
So I decided to make almost pure Python implemented library that is utilizing frame buffer and memory mapping. The only a thing about 'pure' with this library is that it uses PIL library that is default installed python libarary on official Raspbian to convert image formats into raw BGR(A) and is also providing ways to use imagemagick as decompressor.
There are many documents online how to mmap frame buffer with C, but none of similar are with Python, which also has mmap library by default. Actually there aren't so many examples about Python mmap library either. Hope this code helps you to understand how to ioctl and mmap not only frame buffers but also general Linux drivers with pure Python.
pip install
.
dmesg
shows bcm2708_fb soc:fb: Unknown ioctl 0x5401
sudo apt install libjpeg62-turbo-dev libfreetype6-dev libwebp-dev -y
sudo apt install python3-pip
sudo pip3 install fbpygif
sudo apt install git
git clone https://github.com/chidea/FBpyGIF
cd FBpyGIF
sudo python3 setup.py install
These three are identical.
sudo FBpyGIF [directory or file list...]
sudo python3 -m FBpyGIF.main [...]
sudo python3 -m FBpyGIF [...]
FBpyGIF --help
to see all commands.FBpyGIF -ct
will put you into color test mode. (Aware of hypnotising screen ;) )python3 -m FBpyGIF.util size_cat ~/pictures
will categorize pictures based on its sizes and move into folders horizontal, vertical, square under the directory you run it.