11

I'm using CarrierWave::RMagick to create thumbnail versions of images for a Rails app, and I've noticed loss of quality when the images are downsized. This is understandable to a certain extent, as we have less pixels in a downsized image and therefore less quality, but I would expect better quality. I show you an example:

Original Photoshop (Bicubic) RMagick

From left to right, the first one is the original (100x105), the second one is Photoshop's Bicubic resize (95x100), and the third is the result of RMagick's resize_to_fit (95x100).

For this example the original image is only slightly bigger than the thumbnail I want, but I'm basically forcing every thumbnail to be 100x100 max. I hope you can see the difference between the downsized images. It may be silly to compare Photoshop's quality to that of RMagick, but even zooming out in Chrome to make images smaller produces a better quality image.

I'm basically using this in the CarrierWave uploader class:

  version :thumb do
    process :resize_to_fit => [100, 100]
  end

Any ideas on how the image quality can be improved? or if there are any alternatives to RMagick that can do better?

EDIT: I've tried this, though that didn't make any difference. I thought that was for JPEG images anyway.

Merott
  • 7,189
  • 6
  • 40
  • 52
  • Did you ever figure this out? – cman77 Nov 04 '15 at 16:05
  • 1
    Nope, never did. I also couldn't find a better option, so I put up with it :) – Merott Nov 08 '15 at 22:05
  • jpg will help with certain images using many gradients. However, I suspect the issue is with the aging RMagick algorithms used to scale. In photoshop the results are different, I believe that is the cause. One alternitive to RMagick is Jimp but it's totally different and not made for rails. – Eddie Mar 01 '18 at 19:39

1 Answers1

0

The issue appears to be in the imagemagick library, and not specific to carrierwave or rmagick.

You can test this at the command line. Both of these commands produce the same blurry output as rmagick, using imagemagick's own mogrify command:

mogrify -resize 100x100 original.png
mogrify -resize 100x100 -quality 100 original.png

The imagemagick docs suggest that the -resize command (used by carrierwave via rmagick or minimagick) creates blurry results for small changes like the one we're testing here, and you're better off with the -adaptive-resize command, but in my quick testing I wasn't able to produce a better result.

Others have reported better results using graphicsmagick instead of imagemagick (which may also require a switch to minimagick from rmagick), but I haven't tested this.

Taavo
  • 2,406
  • 1
  • 17
  • 17