Components | All | New | MacOS | Windows | Linux | iOS | ||||
Examples | Mac & Win | Server | Client | Guides | Statistic | FMM | Blog | Deprecated | Old |
Quantize image (reduce number of colors).
Component | Version | macOS | Windows | Linux | Server | iOS SDK |
GraphicsMagick | 2.0 | ✅ Yes | ✅ Yes | ✅ Yes | ✅ Yes | ✅ Yes |
Parameter | Description | Example | Flags |
---|---|---|---|
ImageRef | The image reference number. | 1 | |
measureError | Optionally, a boolean value. | 0 | Optional |
Returns "OK" on success.
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.Release";$BigImageRef) ]
This function checks for a license.
Created 18th August 2014, last changed 21st December 2018