Generating thumbnails for images
Many times when downloading an image, you do not want to save the full image, but only a thumbnail. Or you may also save both the full-size image and a thumbnail. Thumbnails can be easily created in python using the Pillow library. Pillow is a fork of the Python Image Library, and contains many useful functions for manipulating images. You can find more information on Pillow at https://python-pillow.org. In this recipe, we use Pillow to create an image thumbnail.
Getting ready
The script for this recipe is 04/07_create_image_thumbnail.py
. It uses the Pillow library, so make sure you have installed Pillow into your environment with pip or other package management tools:
pip install pillow
How to do it
Here is how proceed with the recipe:
Run the script for the recipe. It will execute the following code:
from os.path import expanduser import const from core.file_blob_writer import FileBlobWriter from core.image_thumbnail_generator import ImageThumbnailGenerator...