简体   繁体   English

使用rake任务修剪和压缩回形针的图像

[英]Trimming and Compression the image of paperclip using rake task

I want to trimming the image of paperclip in my database. 我想修剪数据库中回形针的图像。 Because I`m running my own private web service, but I forgot to add the styles when user create the image... 因为我正在运行自己的私有Web服务,但是当用户创建图像时我忘了添加样式...

has_attached_file :avatar,
                  :storage => :s3,
                  :styles => { # I forgot to add this styles
                    :medium => "370x370#", # I forgot to add this styles
                    :thumbs => "120x120#" # I forgot to add this styles
                  }

So I want to run the rake task and trimming like 370×370# and 120×120#. 所以我想运行rake任务并进行修整,例如370×370#和120×120#。 But I cant`t find the way to trimming the image after user save. 但是我找不到用户保存后修剪图像的方法。

Does anyone assist me ? 有人帮我吗?

The paperclip gem comes with a rake task for exactly this purpose: 为此,回形针宝石附带了耙任务:

rake paperclip:refresh:thumbnails

Just run that from the command line and it will take care of generating all of your reduced-size images. 只需从命令行运行该命令,它将负责生成所有尺寸减小的图像。

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

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