问题
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