Combining options in MiniMagick

荒凉一梦 提交于 2019-12-13 08:47:30

问题


I'm trying out MiniMagick for some image manipulation but I'm having trouble combining commands. I want to use the trim command with a fuzz factor.

Calling

image.fuzz "30%"
image.trim

works perfectly. But my understanding is that the fuzz factor will continue to be set for all future commands, which I don't want. Instead I've tried

image.combine_options do |c|
  c.fuzz "30%"
  c.trim
end

but unfortunately this doesn't seem to do anything (unless I set the fuzz factor to 100% in which case it correctly removes every pixel from the image—fuzz at 99%, however, does nothing).

What am I doing wrong? Many thanks in advance!


回答1:


Ah, I forgot to add the +repage option to trim. This works:

image.combine_options do |c|
  c.fuzz "30%"
  c.trim "+repage"
end


来源:https://stackoverflow.com/questions/17754313/combining-options-in-minimagick

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!