What is it?
Ever wanted to convert a picture into an spreadheet? Pictures are made up of pixels, millions of tiny dots that when combined create an imagine. This program takes each pixel and identifies it's colour, then loads the spreadsheet program and plots out each pixel as a coloured cell. All the combined cells create the original image as a cool spreadsheet version.
1. Getting Started
This project uses Raspberry Pi 2 and the latest version of Raspbian, (21.5.2015) Python 2.79 was used, although it will work on previous and future versions. Firstly update your Raspberry Pi:
In the LX Terminal type:
sudo apt-get update
sudo apt-get upgrade
Next up install the software:
sudo install –-upgrade pip
sudo pip install -U pip
pip install Pillow
pip install xlwt
Next you will need a spreadsheet program to create the coloured cells. Libre office comes with a suitable spreadsheet package that can be used to for this purpose and can be easily installed, type: sudo apt-get install libreoffice-calc Once installed you are now ready to download the conversion program.
2. Covert Pixels to Cells
Now all the modules are installed the next stage is to download the Image to Spreadsheet software, PNG to XLS. Click the link below and download the file, save it to the pi/home folder. You can run the program from any folder as long as this program png2xls.py and the PNG image to covert are in the same folder.
Return back to the LX Terminal and type,
sudo python png2xls.py libre name_of_image.png
where name_of_image.png is the name of the picture that you are going to convert, for example, sudo python png2xls.py libre Raspberry_Pi.png. Once the program has finished it will have created a spreadsheet of the PNG image.
You can use WinSCP or a similar program to transfer the spreadheet from the Pi to your computer,it is an open source free SFTP client and FTP client for Windows the main function is the secure file transfer between local and remote computer.
Raspberry Pi to Excel
3. Live Conversion
A good extension to the hack is to add a USB Webcam, take a picture of yourself and then have the code convert it into your own self spreadsheet portrait. This uses the PyGame camera module to assess the web camera and save the photo. This already installed on the Raspberry Pi and can controlled with the code below.
cam = pygame.camera.Camera(pygame.camera.list_cameras())
img = cam.get_image()
Download the code below and run the program from the LX Terminal typing:
sudo python camera2xls.py libre photo.png Note that the image file is called photo.png and is the default name that the image file is saved as.