GMImage.SetMatte
----------------

Sets whether image supports transparency (matte channel)

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

MBS( "GMImage.SetMatte"; ImageRef; Flag ) 

**MBS**( **"GMImage.SetMatte";** /\* Sets whether image supports transparency (matte channel) \*/  
**$ImageRef**; /\* The image reference number.e.g. 1 \*/   
**$Flag**) /\* A boolean value.e.g. 1 \*/ 

### Parameters

| Parameter | Description | Example |
|---|---|---|
| ImageRef | The image reference number. | 1 |
| Flag | A boolean value. | 1 |

### Result

Returns "OK" on success.

### Description

Sets whether image supports transparency (matte channel)  
### Examples

Removes alpha channel:

 MBS ("GMImage.SetMatte"; $image ; 0)  
Adds an alpha channel:

 MBS ("GMImage.SetMatte"; $image ; 1)  
Create picture with red and 50% alpha:

 #Create picture   
Set Variable \[$img ; Value:MBS ( "[GMImage.New](GMImageNew.md)"; "16x16"; "white")\]  
\#Add alpha channel   
Set Variable \[$r ; Value:MBS ( "GMImage.SetMatte"; $img ; 1)\]  
\#Set background color and fill   
Set Variable \[$r ; Value:MBS ( "[GMImage.SetBackgroundColor](GMImageSetBackgroundColor.md)"; $img ; "COLOR 65535 0 0 0.5 ")\]  
Set Variable \[$r ; Value:MBS ( "[GMImage.Erase](GMImageErase.md)"; $img )\]  
\#Write to field   
Set Variable \[$pic ; Value:MBS ( "[GMImage.WriteToPNGContainer](GMImageWriteToPNGContainer.md)"; $img ; "test.png" )\]  
Set Field \[test::r ; $pic \]  
\#Cleanup   
Set Variable \[$r ; Value:MBS ( "[GMImage.Release](GMImageRelease.md)"; $img )\]  
Remove alpha channel:

 # Load from container   
Set Variable \[ $BigImageRef ; Value: MBS ("[GMImage.NewFromContainer](GMImageNewFromContainer.md)"; Test::BigImage ) \]   
\# Turn off alpha channel   
Set Variable \[ $Result ; Value: MBS ("GMImage.SetMatte"; $BigImageRef ; 0) \]   
\# Store output and release the image   
Set Field \[ Test::Result ; MBS ( "[GMImage.WriteToPNGContainer](GMImageWriteToPNGContainer.md)"; $BigImageRef ) \]   
\# or JPEG?   
// Set Field \[ Test::Result ; MBS ( "[GMImage.WriteToJPEGContainer](GMImageWriteToJPEGContainer.md)"; $BigImageRef ) \]   
Set Variable \[ $Error ; Value: MBS ("[GMImage.Free](GMImageFree.md)";$BigImageRef ) \]  
### See also

- [GMImage.GetMatte](GMImageGetMatte.md)
- [GMImage.SetDepth](GMImageSetDepth.md)
- [GMImage.SetFont](GMImageSetFont.md)
- [GMImage.SetLabel](GMImageSetLabel.md)
- [GMImage.SetMagick](GMImageSetMagick.md)
- [GMImage.SetPage](GMImageSetPage.md)
- [GMImage.SetScene](GMImageSetScene.md)
- [GMImage.SetSize](GMImageSetSize.md)
- [GMImage.Trim](GMImageTrim.md)
- [GMImage.WriteToJPEGContainer](GMImageWriteToJPEGContainer.md)

### Example Databases

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

This function checks for a license.

Created 18th August 2014 , last changed 17th August 2023

  
[GMImage.SetMagick](GMImageSetMagick.md) - [GMImage.SetMatteColor](GMImageSetMatteColor.md)

[HTML Version](GMImageSetMatte.shtml)