Clip: specify quality jpeg / jpg

Is there an easy way to specify the quality of the jpeg image to be saved in the clip clip for rails 3?

+8
ruby-on-rails paperclip
source share
2 answers

Yes, that’s pretty easy. Paperclip has an option: convert_options, which can be used for this purpose. It accepts parameters that ImageMagick / Ghostscript can accept.

Here is an example:

class User < ActiveRecord::Base has_attached_file :avatar, :styles => { :thumb => ["100x100>", :jpg] }, :convert_options => { :thumb => "-quality 92" } 
+14
source share

Based on @DanneManne's answer, if you want to convert the original image and not add another style, just define a style with the name :original and set convert_options for it convert_options this:

 has_attached_file :image, styles: { original: {} }, convert_options: { original: "-quality 10" } 
0
source share

Source: https://habr.com/ru/post/650862/


All Articles