GMImage.Flatten
---------------

Flatten the alpha channel.

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

MBS( "GMImage.Flatten"; ImageRef ) 

**MBS**( **"GMImage.Flatten";** /\* Flatten the alpha channel. \*/  
**$ImageRef**) /\* The image reference number.e.g. 1 \*/ 

### Parameters

| Parameter | Description | Example |
|---|---|---|
| ImageRef | The image reference number. | 1 |

### Result

Returns OK or error.

### Description

Flatten the alpha channel.  
Please set background color to define what color goes into the transparent areas.  
### Examples

Removes alpha channel:

 # Load from container   
Set Variable \[ $BigImageRef ; Value: MBS ("[GMImage.NewFromContainer](GMImageNewFromContainer.md)"; Test::BigImage ) \]  
\# set the color to use for transparent areas   
Set Variable \[ $Result ; Value: MBS ("[GMImage.SetBackgroundColor](GMImageSetBackgroundColor.md)"; $BigImageRef ; "white") \]  
\# and remove transparency   
Set Variable \[ $Result ; Value: MBS ("GMImage.Flatten"; $BigImageRef ) \]  
\# Store output and release the image   
Set Field \[ Test::Result ; MBS ( "[GMImage.WriteToJPEGContainer](GMImageWriteToJPEGContainer.md)"; $BigImageRef ) \]  
Set Variable \[ $Error ; Value: MBS ("[GMImage.Free](GMImageFree.md)";$BigImageRef ) \]  
### See also

- [GMImage.FillPattern](GMImageFillPattern.md)
- [GMImage.Free](GMImageFree.md)
- [GMImage.New](GMImageNew.md)
- [GMImage.NewFromContainer](GMImageNewFromContainer.md)
- [GMImage.Rotate](GMImageRotate.md)
- [GMImage.SetBackgroundColor](GMImageSetBackgroundColor.md)
- [GMImage.Sharpen](GMImageSharpen.md)
- [GMImage.WriteToJPEGContainer](GMImageWriteToJPEGContainer.md)

### Release notes

- **Version 14.2**
    - Added [GMImage.Flatten](https://www.mbsplugins.eu/GMImageFlatten.shtml) function to remove alpha channel from image.

### Example Databases

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

### Blog Entries

- [Neues MBS Plugin 14.2 für Claris FileMaker](https://www.mbsplugins.de/archive/2024-05-14/Neues_MBS_Plugin_142_für_Clar/monkeybreadsoftware_blog_filemaker)
- [MBS Plugin 14.2 for Claris FileMaker](https://www.mbsplugins.de/archive/2024-05-14/MBS_Plugin_142_for_Claris_File/monkeybreadsoftware_blog_filemaker)
- [MBS FileMaker Plugin, version 14.2pr5](https://www.mbsplugins.de/archive/2024-05-08/MBS_FileMaker_Plugin_version_1/monkeybreadsoftware_blog_filemaker)

This function checks for a license.

Created 6th May 2024 , last changed 25th February 2026

  
[GMImage.FindColorInRow](GMImageFindColorInRow.md) - [GMImage.Flip](GMImageFlip.md)

[HTML Version](GMImageFlatten.shtml)