如何使用 Paperclip gem 调用液体重新缩放?
我正在将 Paperclip gem 与 Rails 3.1.1 应用程序一起使用。它按照广告和预期工作。不过,我想使用 imagemagick -liquid-rescale
委托。根据imagemagick文档(我在terminal.app中尝试过),这有效:
convert logo_trimmed.jpg -liquid-rescale 75x100%\! logo_lqr.jpg
我尝试了一种变体...
convert my_pic.jpg -liquid-rescale 60x60\! my_new_pic.jpg
它也按预期工作。我已经在 Rails 应用程序的图像模型中尝试了几种排列,但我无法让 Paperclip 调用液体重新缩放。我最近的尝试是:
has_attached_file :pic, :styles => {:square => "-liquid-rescale 60x60\!" }
这失败了,没有错误消息,只是用新名称复制原始图像。
如何指示回形针调用液体重新缩放?
I'm using the Paperclip gem with a Rails 3.1.1 app. It's working as advertised and expected. I would like to use the imagemagick -liquid-rescale
delegate, however. According to the imagemagick documentation (which I tried in terminal.app), this works:
convert logo_trimmed.jpg -liquid-rescale 75x100%\! logo_lqr.jpg
I tried a variation...
convert my_pic.jpg -liquid-rescale 60x60\! my_new_pic.jpg
That worked as expected, too. I've tried several permutations in my Image model in my rails app, but I cannot get Paperclip to invoke liquid-rescale. My latest attempt was:
has_attached_file :pic, :styles => {:square => "-liquid-rescale 60x60\!" }
This fails without an error message, merely duplicating the original image with a new name.
How do I instruct paperclip to invoke liquid-rescale?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这就是我所做的。我必须编写一个自定义处理器,我将其命名为
liquid
。在模型中:我不确定
:geometry
选项是否必要,但我添加了它,因为 <回形针 gem 中的 code>thumbnail.rb 表示它不是可选的。然后我添加了一个文件:
/my_app/lib/paperclip_processors/liquid.rb
,其内容为:最后,我在控制台中运行了以下命令:
这就成功了。
Here's what I did. I had to write a custom processor, which I named
liquid
.In the model:I'm not sure whether the
:geometry
option is necessary, but I added it becausethumbnail.rb
in the paperclip gem says that it's not optional.I then added a file:
/my_app/lib/paperclip_processors/liquid.rb
with contents:Finally, I ran the following in the console:
That did the trick.