Generate a thumbnail image from a Trove newspaper article¶
In another notebook, I showed how to get high-resolution page images from newspapers. But what if you only want a nice square thumbnail for display purposes? This notebook gets the page image and then crops and resizes the top of the article to create a thumbnail.
Of course, if you're doing this to lots of articles you won't want to feed each one in manually. If you're viewing this notebook in app mode (no code visible), just click on the 'Edit app' button to see what's going on behind the scenes. You should be able to copy and modify the code to suit your purposes.
Briefly, the steps to generate a thumbnail are:
- Scrape the article's HTML page to get the page identifier and the coordinates of the article on the page
- Use the page identifier to download a high-res page image
- Crop a square image from the page using the coordinates
- Resize the cropped image
Enter an article url...¶
You can use the url in your browser's location bar or an article permalink.
Optional settings¶
Generate a square thumbnail with this height and width (in pixels).
If there's an illustration in the article, check this box to use it as the thumbnail. The illustration will not be cropped, so whitespace will be added around the image to make it square.
Get the thumbnail!¶
Created by Tim Sherratt for the GLAM Workbench.
Support this project by becoming a GitHub sponsor.