简体   繁体   中英

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...

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#. 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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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