In The Wild
How it works
Every theme or plugin can register new image sizes. Every uploaded image will be resized to that size, regardless if it will ever be used. This plugin makes sure that the image is only resized when it is actually requested.
Make sure to meet the following requirements:
You need to have Pretty Permalinks enabled, your server must be running PHP 5.5+ and have ImageMagick (and the PHP wrapper) installed (GD works as well for basic operations, but ImageMagick is the preferred way).
When a user requests an image (jpg, png, gif) and it is not present in that size, the plugin hooks into the 404 template redirect and resizes the image to the requested size. If the original image does not exist, a 404 is returned as expected.
This allows you to change or test themes (and plugins) without manually taking care of the image resizing. Moreover, only the sizes that are actually requested are stored on the server.
If you are a developer and interested in how the plugin works, check out the code on GitHub.