存储在S3中缩放图像缩放、图像

2023-09-11 08:29:15 作者:臣服心动?

我在一个情况下,我需要把图像存储为一些网站出来一个可以无限扩展服务(S3,CloudFiles等)。直到此时,我们已经能够让我们的用户使用Python的图像库从的在Django SORL-缩略图。

I'm in a situation where I need to push image storage for a number of websites out to a service that can scale indefinitely (S3, CloudFiles, etc.). Up until this point we've been able to allow our users to generate custom thumbnail sizes on the fly using Python's Imaging library with some help from sorl-thumbnail in Django.

通过将我们的图像,以类似S3,有能力的快速的创建缩略图上飞丢失。我们可以:

By moving our images to something like S3, the ability to quickly create thumbnails on the fly is lost. We can either:

通过下载从S3源和本地创建缩略图要慢慢 CON:它是缓慢和带宽密集型的 请其前期通过创建一个pre确定的设定缩略图的大小(a'la Flickr的),并将其全部推到S3 的 CON:它限制了可以生成以及大小存储大量文件,将永远不会被使用的 使用高度/宽度属性的img标签让浏览器调整大小。 CON:用于通过下载超过必要的文件较​​大的多余带宽的 Do it slowly by downloading the source from S3 and creating the thumbnail locally con: it is slow and bandwidth intensive Do it upfront by creating a pre-determined set of thumbnail sizes (a'la Flickr) and pushing them all to S3 con: it limits the sizes that can be generated and stores lots of files that will never be used Let the browser resize using the height/width attributes on the img tag. con: extra bandwidth used by downloading larger than necessary files

目前点#3看起来是一个简单的解决问题的方法与一些缺点。从本网站的一些快速测试和数据表明,质量ISN 'T一样糟糕预期(我们可以保证率维持方面)。

At this point #3 looks to be a simple solution to the problem with few drawbacks. Some quick tests and data from this website show that the quality isn't as bad as expected (we could assure the aspect ratio is maintained).

其他选项或缺点任何建议,我们可能没有考虑到?

Any suggestions on other options or drawbacks we might not be taking into consideration?

注:图片是数码照片仅用于显示在网页上。尺寸将范围从高度/宽度1000-50像素。的

推荐答案

我会建议使用EC2,以按需扩展的图像。由于EC2和S3之间的带宽是免费的,它应该是快,我认为这消除了所有的问题的解决方案#1。

I would recommend using EC2 to scale the images on demand. Since bandwidth between EC2 and S3 is free and it should be fast I think that eliminates all the problems with solution #1.