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.1   6.2   6.3   6.4   6.5   7.0   7.1   7.2   7.3   7.4    Statistic  

GMImage.Threshold

Threshold image channels (below threshold becomes black, above threshold becomes white).

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

MBS( "GMImage.Threshold"; ImageRef; threshold )

Parameters

Parameter Description Example value
ImageRef The image reference number. 1
threshold The range of the threshold parameter is 0 to MaxRGB (255). 127

Result

Returns "OK" on success.

Description

Threshold image channels (below threshold becomes black, above threshold becomes white).

Examples

Applies a threshold on the image:

Let ( [
$Image = MBS("GMImage.NewFromContainer"; GraphicsMagick::image);
$Result = MBS("GMImage.Threshold";$Image; 127);
$Result = MBS("GMImage.WriteToJPEGContainer"; $Image);
$Error = MBS("GMImage.Destroy";$Image)
];
$Result)

Convert image to 1 bit TIFF:

# Load from container
$Image = MBS("GMImage.NewFromContainer"; GraphicsMagick::image);

# make black and white with threshold
$Result = MBS("GMImage.Threshold";$Image; 127);

# mark as monochrome image
$Result = MBS("GMImage.SetMonochrome";$Image; 1);

# set type to 1 for black/white
$Result = MBS("GMImage.SetType";$Image; 1);

# set to use TIFF for compression
$Result = MBS("GMImage.SetMagick";$Image; "TIFF");

# set to use CCITT 4 Fax compression
$Result = MBS("GMImage.SetCompressType";$Image; 4);

# and write to a file
$Result = MBS("GMImage.WriteToFile"; $Image; "/tmp/test.tif");

# cleanup
$Error = MBS("GMImage.Destroy";$Image)

Make a picture black and transparent:

Set Variable [$image; Value:MBS( "GMImage.NewFromContainer"; Test::BigImage)]
Set Variable [$r; Value:MBS( "GMImage.Threshold"; $image; 127)]
Set Variable [$imagecolor; Value:MBS( "GMImage.Transparent"; $image; "COLOR 255 255 255")]
Set Field [Test::Result; MBS( "GMImage.WriteToPNGContainer"; $image;)]
Set Variable [$Error; Value:MBS("GMImage.Destroy";$image)]

See also

Example Databases


GMImage.Texture   -   GMImage.TotalColors

Feedback: Report problem or ask question.




Links
MBS Xojo PDF Plugins