Page 1 of 1

Using fuzz in Magick++ trim

Posted: 2009-10-01T14:34:12-07:00
by dappermuis
Hi

I need to trim an image but the area I need to trim isn't a single colour so I need to use the fuzz option. It works fine from the command line but I need to be able to do it from Magick++. I've looked at the API and seen that the trim() method doesn't allow you to set a fuzz value and it doesn't seem to take note of the fuzz value set by the colorFuzz() method.

Does anyone have any ideas of how I can achieve this?

Re: Using fuzz in Magick++ trim

Posted: 2009-10-01T15:39:04-07:00
by magick
Fuzz is supported by Magick::Options::colorFuzz(), Magick::Image::colorFuzz(), and with STL Magick::colorFuzzImage::colorFuzzImage().

Re: Using fuzz in Magick++ trim

Posted: 2009-10-01T15:50:32-07:00
by dappermuis
Thanks for the response. I am aware that you can set the colorFuzz() value but Magick::Image::trim() does not seem to obey it.

I did the following.

Image.colorFuzz(50);
Image.trim();

But that does not have any effect.

The following from the command line however produces the correct results:

convert image.png -fuzz 50% -trim output.png

Am I doing something wrong?

Re: Using fuzz in Magick++ trim

Posted: 2009-10-01T16:31:31-07:00
by magick
The command line option has a percentage argument whereas Magick++ does not. For Magick++ you want colorFuzz(50*QuantumRange/100).

Re: Using fuzz in Magick++ trim

Posted: 2009-10-02T00:29:14-07:00
by dappermuis
Aha, perfect! :D
Thanks very much, does the job perfectly :)