Topics   All   MacOS (Only)   Windows (Only)   Linux (Only, Not)   iOS (Only, Not)  
Components   Crossplatform Mac & Win   Server   Client   Old   Deprecated   Guides   Examples   Videos
New in version: 10.0   10.1   10.2   10.3   10.4   10.5   11.0   11.1   11.2   11.3    Statistic    FMM    Blog  

GMImage.SetColorFuzz

Sets the color fuzz.

Component Version macOS Windows Linux Server iOS SDK
GraphicsMagick 2.0 ✅ Yes ✅ Yes ✅ Yes ✅ Yes ✅ Yes
MBS( "GMImage.SetColorFuzz"; ImageRef; value )   More

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 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"; 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.Release";$BigImageRef)]

Make a picture transparent:

#load a picture
Set Variable [$image; Value:MBS( "GMImage.NewFromContainer"; Test::BigImage)]
#white in RGB
Set Variable [$f; Value:"white"]
#Replace all white with nearly white
Set Variable [$r; Value:MBS( "GMImage.ReplaceColor"; $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"; $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;)]
#cleanup
Set Variable [$Error; Value:MBS("GMImage.Release";$image)]

See also

Example Databases

Created 18th August 2014, last changed 25th November 2020


GMImage.SetClassType - GMImage.SetColorMapSize

Feedback: Report problem or ask question.




Links
MBS FileMaker Plugins

Start Chat