2
votes

I got a Carrierwave uploader and process images like this:

version :thumbnail do
    process :resize_to_model
    process :quality => 90   
end

def resize_to_model
  thumbs_size = model.thumbnail_size
  resize_to_fill thumbs_size[:width], thumbs_size[:height]
end

However, after processing an image which was 1024x724px and is 214x151px afterwards the file size only went down from 2,1mb to 1,8mb. I think 1,8mb really is a lot for that size. Can I do something about that? Even with 90% quality the image should be like maybe 100kb or not?

Before someone asks, the rest works perfect. No errors, the size in px is right and everything else is also fine.

Edit: I forgot to mention I Use rmagick(resize_to_fill). Is that a reason maybe?

1

1 Answers

0
votes

The difference between 100% and 90% quality is so small and the storage space savings is negligible. If you are truly just using this version as a thumbnail you should look at using a much lower quality, say 60% or 40%.

If you are concerned about making sure the quality is still "good enough" then you could also look at different compression techniques. The process used to provide @2x images for Retina displays can be used in this instance. A great resource is available in the Filament Group's article Compressive Images.

The tl;dr version is basically, use the original (or near original) size of the image but drastically reduce the image quality (to 0-20%). Then, when using the reduced quality image be sure to provide width and height attributes in the <img> element to resize it down to the thumbnail size. Because the image will be scaled down you will not see the reduction in quality of the "thumbnail" image.