Components All New MacOS Windows Linux iOS
Examples Mac & Win Server Client Guides Statistic FMM Blog Deprecated Old


Sets whether image supports transparency (matte channel)

Component Version macOS Windows Linux Server iOS SDK
GraphicsMagick 2.0 ✅ Yes ✅ Yes ✅ Yes ✅ Yes ✅ Yes
MBS( "GMImage.SetMatte"; ImageRef; flag )   More


Parameter Description Example
ImageRef The image reference number. 1
flag A boolean value. 1


Returns "OK" on success.


Sets whether image supports transparency (matte channel)


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"; "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"; $img; "COLOR 65535 0 0 0.5")]
Set Variable [$r; Value:MBS( "GMImage.Erase"; $img)]
#Write to field
Set Variable [$pic; Value:MBS( "GMImage.WriteToPNGContainer"; $img; "test.png" )]
Set Field [test::r; $pic]
Set Variable [$r; Value:MBS( "GMImage.Release"; $img)]

Remove alpha channel:

# Load from container
Set Variable [ $BigImageRef ; Value: MBS("GMImage.NewFromContainer"; 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"; $BigImageRef ) ]
# or JPEG?
// Set Field [ Test::Result ; MBS( "GMImage.WriteToJPEGContainer"; $BigImageRef ) ]
Set Variable [ $Error ; Value: MBS("GMImage.Free";$BigImageRef) ]

See also

Example Databases

This function checks for a license.

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

GMImage.SetMagick - GMImage.SetMatteColor