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

GMImage.Quantize

Quantize image (reduce number of colors).

Component Version macOS Windows Server FileMaker Cloud FileMaker iOS SDK
GraphicsMagick 2.0 Yes Yes Yes Yes Yes
MBS( "GMImage.Quantize"; ImageRef { ; measureError } )   More

Parameters

Parameter Description Example value
ImageRef The image reference number. 1
measureError Optional
Optionally, a boolean value.
0

Result

Returns "OK" on success.

Description

Quantize image (reduce number of colors).
See GMImage.SetQuantizeColorSpace, GMImage.SetQuantizeColors, GMImage.SetQuantizeDither and GMImage.SetQuantizeTreeDepth for options.

Examples

Quantize picture:

Set Variable [ $BigImageRef ; Value: MBS("GMImage.NewFromContainer"; Test::BigImage) ]
# reduce to 20 colors, so we see the effect. Normally 256
Set Variable [ $Result ; Value: MBS( "GMImage.SetQuantizeColors"; $BigImageRef; 20) // 256 ) ]
# Enable dithering, turn off to really see the effect
Set Variable [ $Result ; Value: MBS( "GMImage.SetQuantizeDither"; $BigImageRef; 1 ) ]
# Quantize to palette colors
Set Variable [ $Result ; Value: MBS( "GMImage.SetQuantizeColorSpace"; $BigImageRef; 4 /* palette */ ) ]
# Do it!
Set Variable [ $Result ; Value: MBS("GMImage.Quantize"; $BigImageRef) ]
# Type should now be 4 for palette
Set Variable [ $Result ; Value: MBS("GMImage.GetType"; $BigImageRef) ]
# save as GIF
Set Field [ Test::Result ; MBS( "GMImage.WriteToGIFContainer"; $BigImageRef ) ]
Set Variable [ $Error ; Value: MBS("GMImage.Destroy";$BigImageRef) ]

See also

Created 18th August 2014, last changed 11st October 2018


GMImage.PushClipPath   -   GMImage.QuantumDepth

Feedback: Report problem or ask question.




Links
MBS Xojo Chart Plugins