Using AWS S3 to Store Photos

I am going to use S3 to store user uploaded photos. Obviously, I will not serve image files for user agents without resizing them. However, more than one size will do, as some thumbnails will be smaller than other larger previews. So, I was thinking of creating a standard set of sizes, scalable from the lowest 16x16 to the highest 1024x1024. Is this a good way to solve this problem? What if I need a new size? How would you solve this?

+7
source share
2 answers

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

+12
source

This seems like a good approach. Depending on your application, you must define the set of thumbnails that you always generate. But also save the original user file if your requirements change later. If you want to add a new sketch size, you can iterate over all the source files and create new thumbnails from it. This option gives you flexibility for later versions.

0
source

All Articles