Search code examples
minimagick

Combining options in MiniMagick


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!


Solution

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

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