Using fuzz in Magick++ trim

Questions and postings pertaining to the usage of ImageMagick regardless of the interface. This includes the command-line utilities, as well as the C and C++ APIs. Usage questions are like "How do I use ImageMagick to create drop shadows?".
Post Reply
dappermuis

Using fuzz in Magick++ trim

Post 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?
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Re: Using fuzz in Magick++ trim

Post by magick »

Fuzz is supported by Magick::Options::colorFuzz(), Magick::Image::colorFuzz(), and with STL Magick::colorFuzzImage::colorFuzzImage().
dappermuis

Re: Using fuzz in Magick++ trim

Post 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?
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Re: Using fuzz in Magick++ trim

Post by magick »

The command line option has a percentage argument whereas Magick++ does not. For Magick++ you want colorFuzz(50*QuantumRange/100).
dappermuis

Re: Using fuzz in Magick++ trim

Post by dappermuis »

Aha, perfect! :D
Thanks very much, does the job perfectly :)
Post Reply