GMImage.Quantize
----------------

Quantize image (reduce number of colors).

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

MBS( "GMImage.Quantize"; ImageRef { ; measureError } ) 

**MBS**( **"GMImage.Quantize";** /\* Quantize image (reduce number of colors). \*/  
**$ImageRef**; /\* The image reference number.e.g. 1 \*/   
**$measureError**) /\* Optional; Optionally, a boolean value.e.g. 0 \*/ 

### Parameters

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

### Result

Returns "OK" on success.

### Description

Quantize image (reduce number of colors).  
See [GMImage.SetQuantizeColorSpace](GMImageSetQuantizeColorSpace.md), [GMImage.SetQuantizeColors](GMImageSetQuantizeColors.md), [GMImage.SetQuantizeDither](GMImageSetQuantizeDither.md) and [GMImage.SetQuantizeTreeDepth](GMImageSetQuantizeTreeDepth.md) for options.  
### Examples

Quantize picture:

 Set Variable \[ $BigImageRef ; Value: MBS ("[GMImage.NewFromContainer](GMImageNewFromContainer.md)"; Test::BigImage ) \]   
\# reduce to 20 colors, so we see the effect. Normally 256   
Set Variable \[ $Result ; Value: MBS ( "[GMImage.SetQuantizeColors](GMImageSetQuantizeColors.md)"; $BigImageRef ; 20) // 256 ) \]   
\# Enable dithering, turn off to really see the effect   
Set Variable \[ $Result ; Value: MBS ( "[GMImage.SetQuantizeDither](GMImageSetQuantizeDither.md)"; $BigImageRef ; 1 ) \]   
\# Quantize to palette colors   
Set Variable \[ $Result ; Value: MBS ( "[GMImage.SetQuantizeColorSpace](GMImageSetQuantizeColorSpace.md)"; $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](GMImageGetType.md)"; $BigImageRef ) \]   
\# save as GIF   
Set Field \[ Test::Result ; MBS ( "[GMImage.WriteToGIFContainer](GMImageWriteToGIFContainer.md)"; $BigImageRef ) \]   
Set Variable \[ $Error ; Value: MBS ("[GMImage.Release](GMImageRelease.md)";$BigImageRef ) \]  
### See also

- [GMImage.Equalize](GMImageEqualize.md)
- [GMImage.GetType](GMImageGetType.md)
- [GMImage.New](GMImageNew.md)
- [GMImage.NewFromContainer](GMImageNewFromContainer.md)
- [GMImage.Release](GMImageRelease.md)
- [GMImage.SetQuantizeColors](GMImageSetQuantizeColors.md)
- [GMImage.SetQuantizeColorSpace](GMImageSetQuantizeColorSpace.md)
- [GMImage.SetQuantizeDither](GMImageSetQuantizeDither.md)
- [GMImage.SetQuantizeTreeDepth](GMImageSetQuantizeTreeDepth.md)
- [GMImage.WriteToGIFContainer](GMImageWriteToGIFContainer.md)

### Example Databases

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

This function checks for a license.

Created 18th August 2014 , last changed 21st December 2018

  
[GMImage.PushClipPath](GMImagePushClipPath.md) - [GMImage.QuantumDepth](GMImageQuantumDepth.md)

[HTML Version](GMImageQuantize.shtml)