This program reduces the filesize of images for faster (and politer) online viewing. With it, you can shrink all the images in your entire website in a single step. Though still somewhat experimental, its results are good enough to be used for all of the images at its home website, including those in the image galleries listed here.
shrinkpix reduces an image's size by first saving the original version, and then applying transformations until either the desired size is met, or no more transformations remain. Although its results may serve a variety of purposes, this program is primarily intended for reducing the filesize of a website's images posted online. In this role, the smaller images it creates can be viewed quicker, and are friendlier to users with limited or metered bandwidth.
This program runs locally on your computer from a console, IDE, or script; can be used to shrink both individual images and all the images in a folder or tree; and comes with utilities to restore and collect the original unshrunk images backed up by the main script. Its shrinking techniques are still open to improvement as shipped, but you may find its code useful for your own goals, and its current results adequate for your own sites.
Per results so far, it's not unusual for this program to shrink an image's filesize from 6M to 200-300k—a 20-30x reduction, with proportionate decreases in load times and bandwidth use, and with no obvious decline in visual quality at normal viewing sizes. Naturally, this also reduces the heft of download packages that embed many images; in one case, a 250M zipfile shrunk to 110M.
Perhaps most importantly, this program can make the impractical practical: for sites like learning-python.com with hundreds (or thousands) of images, this program's rare quality reductions are more than outweighed by the time savings of its conversion automation.
To get shrinkpix, download its zipfile from here, and unzip it to a folder on your device. Usage details are available in the top-of-file docstring of the main script, described in the next section.
This program is shipped as Python source code that you run from a console or IDE. It uses and requires both Python 3.X and the Pillow third-party library, and should work on any platform that supports both. This program also uses the piexif third-party library in a minor role, but ships this library's code with its own.
Fine print: in testing to date, shrinkpix has been verified to work correctly on Mac OS 10.11 and later, and Windows 10; using Python 3.5 and 3.6; with Pillow 4.2, 5.1, and 7.0. Its results have no visual-quality difference across these platforms and software versions (and usually yield byte-for-byte identical image files on the same platform). shrinkpix is also expected to work on Linux, Android, and others.
This program was last changed: March 11, 2020.
For a program that generates image galleries that may benefit from shrinkpix resizing when viewed online, see the thumbspage program, including its usage note on image-size issues. For more programs from the makers of shrinkpix, visit the examples page.