Topics   All   MacOS (Only)   Windows (Only)   Linux (Only, Not)   iOS (Only, Not)  
Components   Crossplatform Mac & Win   Server   Client   Old   Deprecated   Guides   Examples   Videos
New in version: 12.2   12.3   12.4   12.5   13.0   13.1   13.2   13.3   13.4   13.5    Statistic    FMM    Blog  

GMImage.SetMatte

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

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"; "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]
#Cleanup
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

💬 Ask a question or report a problem