如何改善里面的Rails / Paperclip图像压缩或ImageMagick / Rmagick? [英] How do I improve Rails / Paperclip image compression inside or ImageMagick / Rmagick?

查看:233
本文介绍了如何改善里面的Rails / Paperclip图像压缩或ImageMagick / Rmagick?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Paperclip在rails中裁剪图像。

I'm using Paperclip to crop an image in rails.

我使用这些转换选项:

"-quality #{attachment.quality} \
 -crop #{attachment.width}x#{attachment.height}+#{attachment.x}+#{attachment.y}"

如果我裁剪并将图像保存为质量为65%的JPEG图像,可怕的,但仍然有相当大的图像尺寸。

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.

然而,如果我使用Image Bucket Pro并做同样的事情,那么JPEG看起来要好得多较小的文件大小。

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.

如何在不降低质量的情况下提高Paperclip(ImageMagick / Rmagick)以提高图像质量和缩小文件大小?

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?

另外:我尝试在图像上放置轻微的高斯模糊并剥离其EXIF数据。但是这对文件大小的影响可以忽略不计。

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.

推荐答案

当你改变时,我不知道Paperclip本身会发生什么质量百分比,但如果您正在寻找一种减少图像文件大小同时保持质量的好方法,我建议您查看这些宝石:

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

由于您正在使用Paperclip,您还可以使用它来自动管理它而无需使用命令行(它使用引擎盖下的图像优化):

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

这篇关于如何改善里面的Rails / Paperclip图像压缩或ImageMagick / Rmagick?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆