How can I reduce the quality of an uploading image using Paperclip?

后端 未结 4 2077
無奈伤痛
無奈伤痛 2021-01-18 08:26

I am running Ruby on Rails 3 and I would like to reduce the quality of an uploading image using the Paperclip plugin/gem. How can I do that?


A

4条回答
  •  既然无缘
    2021-01-18 08:52

    As James says, once you figure out the correct arguments to pass to ImageMagick's convert by experimenting on the command line, you can pass these in to Paperclip through the convert_options option as in James' example.

    If you have multiple arguments, pass them in as an array. Here's an example which I laboured over for a while:

    :convert_options => {:medium => ["-shave", "2x2", "-background", "white", 
                                     "-gravity", "center", "-extent", 
                                     "530x322", "+repage"],
                         :small  => ["-shave", "1x1"] }
    

提交回复
热议问题