Topics   All   Mac OS X (Only)   Windows (Only)   Linux (Only, Not)   iOS (Only, Not)  
Components   Crossplatform Mac & Win   Server (Not)   Client   Old   Guides   Examples
New in version: 6.4   6.5   7.0   7.1   7.2   7.3   7.4   7.5   8.0   8.1    Statistic  


Sets the color fuzz. Colors within this distance are considered equal.

Component Version macOS Windows Server FileMaker Cloud FileMaker iOS SDK
GraphicsMagick 2.0 Yes Yes Yes Yes Yes

MBS( "GMImage.SetColorFuzz"; ImageRef; value )


Parameter Description Example value
ImageRef The image reference number. 1
value a float number. 1.0


Returns "OK" on success.


Sets the color fuzz. Colors within this distance are considered equal.
Used for example with GMImage.Trim function.
Range is from 0 to 255 with zero being no fuzz and 255 to match all colors.
Useful range may be around 50.


Trim a picture:

Set Variable [$BigImageRef; Value:MBS("GMImage.NewFromContainer"; Test::BigImage)]
Set Variable [$Result; Value:MBS( "GMImage.SetBackgroundColor"; $BigImageRef; "white" )]
Set Variable [$Result; Value:MBS( "GMImage.SetColorFuzz"; $BigImageRef; 100 )]
Set Variable [$Result; Value:MBS("GMImage.Trim"; $BigImageRef)]
Set Field [Test::Result; MBS( "GMImage.WriteToJPEGContainer"; $BigImageRef )]
Set Variable [$Error; Value:MBS("GMImage.Destroy";$BigImageRef)]

Make a picture transparent:

#load a picture
Set Variable [$image; Value:MBS( "GMImage.NewFromContainer"; Test::BigImage)]
#white in RGB
Set Variable [$f; Value:"COLOR 255 255 255"]
#Replace all white with nearly white
Set Variable [$r; Value:MBS( "GMImage.ReplaceColor"; $image; $f; "COLOR 255 254 255"; 0)]
#now flood fill it with 5 as tolerance
Set Variable [$r; Value:MBS( "GMImage.SetColorFuzz"; $image; 5 )]
Set Variable [$r; Value:MBS( "GMImage.FloodFillColorXY"; $image; 0; 0; $f )]
#now set back fuzz and make transparent using white
Set Variable [$r; Value:MBS( "GMImage.SetColorFuzz"; $image; 0 )]
Set Variable [$imagecolor; Value:MBS( "GMImage.Transparent"; $image; $f)]
#write back to container
Set Field [Test::Result; MBS( "GMImage.WriteToPNGContainer"; $image;)]
Set Variable [$Error; Value:MBS("GMImage.Destroy";$image)]

See also

Example Databases

GMImage.SetClassType   -   GMImage.SetColorMapSize

Feedback: Report problem or ask question.

MBS Xojo Plugins