问题
I'm using Paperclip to crop an image in rails.
I use these convert options:
"-quality #{attachment.quality} \
-crop #{attachment.width}x#{attachment.height}+#{attachment.x}+#{attachment.y}"
If I crop and save the image as a JPEG with 65% quality the image comes out awful and still has quite a large image size.
However if I use Image Bucket Pro and do the exact same thing, the JPEG comes out looking much better and with a smaller file size.
What can I do to Paperclip (ImageMagick / Rmagick) to improve the image quality and reduce the file size without having such a drastic drop in quality?
Also: I have tried putting a slight Guassian blur on the image and stripping its EXIF data. However this has a negligible effect on the file size.
回答1:
I don't know what's going on within Paperclip itself when you alter the quality percentage, but if you're looking for a great way to reduce image file size while maintaining quality, I'd recommend looking into these gems:
https://github.com/toy/image_optim
https://github.com/grosser/smusher
Since you're using Paperclip, you can also use this to manage it in an automated fashion without the need to use the command line (it uses image optim under the hood):
https://github.com/janfoeh/paperclip-optimizer
来源:https://stackoverflow.com/questions/30263290/how-do-i-improve-rails-paperclip-image-compression-inside-or-imagemagick-rma