GMImage.SetColorFuzz
--------------------

Sets the color fuzz.

| Component | Version | macOS | Windows | Linux | Server | iOS SDK |
|---|---|---|---|---|---|---|
| [GraphicsMagick](component_GraphicsMagick.md) | [2.0](newinversion20.md) | ✅ Yes | ✅ Yes | ✅ Yes | ✅ Yes | ✅ Yes |

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

**MBS**( **"GMImage.SetColorFuzz";** /\* Sets the color fuzz. \*/  
**$ImageRef**; /\* The image reference number.e.g. 1 \*/   
**$Value**) /\* a float number.  
  
Since MBS Plugin 9.x uses 16-bit values, please multiple by 257 to expand older 8-bit values to 16-bit.e.g. 50 \* 257 \*/ 

### Parameters

| Parameter | Description | Example |
|---|---|---|
| ImageRef | The image reference number. | 1 |
| Value | a float number.      Since MBS Plugin 9.x uses 16-bit values, please multiple by 257 to expand older 8-bit values to 16-bit. | 50 \* 257 |

### Result

Returns "OK" on success.

### Description

Sets the color fuzz.   
Colors within this distance are considered equal.  
Used for example with [GMImage.Trim](GMImageTrim.md) function.  
Range is from 0 to 65535 with zero being no fuzz and 65535 to match all colors.  
Useful range may be around 50\*257.  
### Examples

Trim a picture:

 Set Variable \[$BigImageRef ; Value:MBS ("[GMImage.NewFromContainer](GMImageNewFromContainer.md)"; Test::BigImage )\]  
Set Variable \[$Result ; Value:MBS ( "[GMImage.SetBackgroundColor](GMImageSetBackgroundColor.md)"; $BigImageRef ; "white" )\]  
Set Variable \[$Result ; Value:MBS ( "GMImage.SetColorFuzz"; $BigImageRef ; 50\*257 )\]  
Set Variable \[$Result ; Value:MBS ("[GMImage.Trim](GMImageTrim.md)"; $BigImageRef )\]  
Set Field \[Test::Result ; MBS ( "[GMImage.WriteToJPEGContainer](GMImageWriteToJPEGContainer.md)"; $BigImageRef )\]  
Set Variable \[$Error ; Value:MBS ("[GMImage.Release](GMImageRelease.md)";$BigImageRef )\]  
Make a picture transparent:

 #load a picture   
Set Variable \[$image ; Value:MBS ( "[GMImage.NewFromContainer](GMImageNewFromContainer.md)"; Test::BigImage )\]  
\#white in RGB   
Set Variable \[$f ; Value:"white"\]  
\#Replace all white with nearly white   
Set Variable \[$r ; Value:MBS ( "[GMImage.ReplaceColor](GMImageReplaceColor.md)"; $image ; $f ; "white"; 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](GMImageFloodFillColorXY.md)"; $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](GMImageTransparent.md)"; $image ; $f )\]  
\#write back to container   
Set Field \[Test::Result ; MBS ( "[GMImage.WriteToPNGContainer](GMImageWriteToPNGContainer.md)"; $image ;)\]  
\#cleanup   
Set Variable \[$Error ; Value:MBS ("[GMImage.Release](GMImageRelease.md)";$image )\]  
### See also

- [GMImage.FloodFillColorXY](GMImageFloodFillColorXY.md)
- [GMImage.GetColorFuzz](GMImageGetColorFuzz.md)
- [GMImage.GetColorMap](GMImageGetColorMap.md)
- [GMImage.GetPixelColor](GMImageGetPixelColor.md)
- [GMImage.New](GMImageNew.md)
- [GMImage.NewFromContainer](GMImageNewFromContainer.md)
- [GMImage.ReplaceColor](GMImageReplaceColor.md)
- [GMImage.SetBackgroundColor](GMImageSetBackgroundColor.md)
- [GMImage.SetColorSpace](GMImageSetColorSpace.md)
- [GMImage.Trim](GMImageTrim.md)

### Example Databases

- [GraphicsMagick/Trim Picture](https://www.mbsplugins.eu/MBS-FileMaker-Plugin-Examples/GraphicsMagick/Trim%20Picture.shtml#4ScriptAnchor_)

This function checks for a license.

Created 18th August 2014 , last changed 14th October 2022

  
[GMImage.SetClassType](GMImageSetClassType.md) - [GMImage.SetColorMap](GMImageSetColorMap.md)

[HTML Version](GMImageSetColorFuzz.shtml)