thumbsupply
thumbsupply copied to clipboard
Support Image Thumbnails
I recently ran into a case where I needed to support thumbnails for my images too, so that I'm not sending so many bytes over the wire for listing pages. It was easy enough to extend thumbsupply to support images using the convert
program from the imagemagick
software.
Using the convert
program with the resize
argument, we can generate a thumbnail with the same aspect ratio that fits within the specified dimensions. For example, convert infile.png -resize 240x240 outfile.png
will create a file with the same aspect ratio as infile.png
but fitting within 240x240
.
test/test-image.png
is in the public domain. I have downloaded it from publicdomainpng.com.
test/test-animated-gif.gif
is downloaded from wikimedia commons and it's listed as being in the public domain: https://commons.wikimedia.org/wiki/Category:Animated_Earth#/media/File:BlackMarble_2016_rotating_globe_at_night_transparent.gif
To generate thumbnails of images, the computer will need Imagemagick installed. I've noted this in the Readme.