Displaying photo information in an application
In this example, we shall create a utility class for handling photos that can be used by other applications (as a module) to access Photo metadata and display preview images easily.
Getting ready
The following script makes use of Python Image Library (PIL); a compatible version for Python 3 is Pillow.
Pillow has not been included in the Raspbian repository (used by apt-get
); therefore, we will need to install Pillow using a Python Package Manager called
PIP.
To install packages for Python 3, we will use the Python 3 version of PIP (this requires 50 MB of available space).
The following commands can be used to install PIP:
sudo apt-get update sudo apt-get install python3-pip
Before you use PIP, ensure that you have installed libjpeg-dev
to allow Pillow to handle JPEG files. You can do this using the following command:
sudo apt-get install libjpeg-dev
Now you can install Pillow using the following PIP command:
sudo pip-3.2 install pillow
PIP also...