简体   繁体   English

使用Amazon S3的回形针调整图像大小

[英]Resize images with paperclip with amazon s3

I am using paperclip gem for uploading images to s3 amazone. 我正在使用回形针gem将图像上传到s3 amazone。 Three copy of images are uploading - one is real and two are of different resolution like 10x10,50x50. 正在上传三份图片-一幅是真实的,两幅具有不同的分辨率,例如10x10,50x50。

Now I want to upload 5 copy of images like 10x10, 20x20 ,...... This can be done by specifying size in model. 现在,我要上传5张图像的副本,例如10x10、20x20 ............这可以通过在模型中指定尺寸来完成。

But what about the existing images on s3. 但是s3上的现有图像呢? How to create copy of existing images on s3 ? 如何在s3上创建现有图像的副本?

You can specify the style in the model 您可以在模型中指定样式

styles => { :first=> "10x10", :second=> "20x20", :third=> "30x30", ....},

and after you made your new styles just use the rake task paperclip provides 在您制作了新样式后,只需使用rake任务回形针即可

rake paperclip:refresh CLASS=User

where User is the model in this case 在这种情况下,用户是模型

This will go on every user and regenerate the images 这将对每个用户进行,并重新生成图像

see more here https://github.com/thoughtbot/paperclip/wiki/Thumbnail-Generation 在此处查看更多信息https://github.com/thoughtbot/paperclip/wiki/Thumbnail-Generation

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM