Providing different sizes and saving them in S3 is a great approach, especially if you know what sizes you need, you probably will use all sizes for all images and not have so many images and sizes at which the storage cost is excessive.
Here is another approach that I use when I donβt want to pre-generate and store all the different sizes for each image, or when I donβt know what sizes I will use in the future:
Save the original size in S3.
Launch a web server that can request any desired size from the source image.
Hold the CDN (CloudFront) in front of the web server.
Your website or application can now request a URL, such as /16x16/someimage.jpg from CloudFront. The first time this happens, CloudFront will receive a resized image from your web server, but then CloudFront will cache the image and serve it for you, significantly reducing the amount of traffic that gets to your web server.
Here is a service that resizes images from arbitrary URLs, serving them through CloudFront: http://filter.to
Eric hammond
source share