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

GMImage.Transparent

Add matte image to image, setting pixels matching color to transparent

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

Parameters

Parameter Description Example
ImageRef The image reference number. 1
Color A color specification.
Multiple formats are supported including various color names and # with hex number.
See FAQ for details.
"RGB 1 0 0"

Result

Returns "OK" on success.

Description

Add matte image to image, setting pixels matching color to transparent

Examples

Make a picture transparent:

#load a picture
Set Variable [$image; Value:MBS( "GMImage.NewFromContainer"; Test::BigImage)]
#white in RGB
Set Variable [$f; Value:"COLOR 65535 65535 65535"]
#Replace all white with nearly white
Set Variable [$r; Value:MBS( "GMImage.ReplaceColor"; $image; $f; "COLOR 65535 65278 65535"; 0)]
#now flood fill it with 5 as tolerance
Set Variable [$r; Value:MBS( "GMImage.SetColorFuzz"; $image; 5 )]
Set Variable [$r; Value:MBS( "GMImage.FloodFillColorXY"; $image; 0; 0; $f )]
#now set back fuzz and make transparent using white
Set Variable [$r; Value:MBS( "GMImage.SetColorFuzz"; $image; 0 )]
Set Variable [$imagecolor; Value:MBS( "GMImage.Transparent"; $image; $f)]
#write back to container
Set Field [Test::Result; MBS( "GMImage.WriteToPNGContainer"; $image;)]
#cleanup
Set Variable [$Error; Value:MBS("GMImage.Release";$image)]

See also

This function checks for a license.

Created 18th August 2014, last changed 30th June 2026


GMImage.Translation - GMImage.Trim


MarkDown version: GMImageTransparent.md