AutomateTheBoringStuff.Ch17.Projects package¶
Submodules¶
AutomateTheBoringStuff.Ch17.Projects.P1_remixResizeAndAddLogo module¶
Remix resize and add logo
The P3_resizeAndAddLogo
program in this chapter works with PNG and JPEG files,
but PIL.Image
supports many more formats than just these two. Extend
P3_resizeAndAddLogo
to process GIF and BMP images as well.
Another small issue is that the program modifies PNG and JPEG files only if their
file extensions are set in lowercase. For example, it will process zophie.png
but
not zophie.PNG
. Change the code so that the file extension check is case insensitive.
Finally, the logo added to the bottom-right corner is meant to be just a small mark,
but if the image is about the same size as the logo itself, the result will look
ugly. Modify P3_resizeAndAddLogo
so that the image must be at least
twice the width and height of the logo image before the logo is pasted. Otherwise,
it should skip adding the logo.
AutomateTheBoringStuff.Ch17.Projects.P2_findPhotoFolders module¶
Find photo folders
This program identifies all folders in /home/jose
where over 50%
of the files are images of a specified size.
AutomateTheBoringStuff.Ch17.Projects.P3_seatingCards module¶
Seating cards
Chapter 13 included a practice project to create custom invitations from a list of
guests in a plaintext file - P3_invitations
. As an additional project, use
PIL
to create images for custom seating cards for your guests. For each of
the guests listed in guests.txt
, generate an image file with the guest’s name and
some flowery decoration.
To ensure that each seating card is the same size, add a black rectangle on the edges
of the invitation image so that when the image is printed out, there will be a
guideline for cutting. The PNG files that PIL.Image
produces are set
to 72 pixels per inch, so a 4×5-inch card would require a 288×360-pixel image.
Note
- Flowery decoration from: http://www.reusableart.com/flower-02.html