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: 11.3   11.4   11.5   12.0   12.1   12.2   12.3   12.4   12.5   13.0    Statistic    FMM    Blog  

GMImage.CompositeXY

Compose an image onto another at specified offset and using specified algorithm.

Component Version macOS Windows Linux Server iOS SDK
GraphicsMagick 2.0 ✅ Yes ✅ Yes ✅ Yes ✅ Yes ✅ Yes
MBS( "GMImage.CompositeXY"; ImageRef; OtherImageRef; xOffset; yOffset { ; CompositeOperator } )   More

Parameters

Parameter Description Example Flags
ImageRef The image reference number. 1
OtherImageRef The second image reference (a number returned from the GMImage.New functions) 2
xOffset The x offset. 0
yOffset The y offset. 0
CompositeOperator Optional operator.
Can be one of the following numbers:
UndefinedCompositeOp = 0, OverCompositeOp = 1, InCompositeOp = 2, OutCompositeOp = 3, AtopCompositeOp = 4, XorCompositeOp = 5, PlusCompositeOp = 6, MinusCompositeOp = 7, AddCompositeOp = 8, SubtractCompositeOp = 9, DifferenceCompositeOp = 10, MultiplyCompositeOp = 11, BumpmapCompositeOp = 12, CopyCompositeOp = 13, CopyRedCompositeOp = 14, CopyGreenCompositeOp = 15, CopyBlueCompositeOp = 16, CopyOpacityCompositeOp = 17, ClearCompositeOp = 18, DissolveCompositeOp = 19, DisplaceCompositeOp = 20, ModulateCompositeOp = 21, ThresholdCompositeOp = 22, NoCompositeOp = 23, DarkenCompositeOp = 24, LightenCompositeOp = 25, HueCompositeOp = 26, SaturateCompositeOp = 27, ColorizeCompositeOp = 28, LuminizeCompositeOp = 29, CopyCyanCompositeOp = 32, CopyMagentaCompositeOp = 33, CopyYellowCompositeOp = 34, CopyBlackCompositeOp = 35, DivideCompositeOp = 36.
Default is 2.
2 Optional

Result

Returns "OK" on success.

Description

Compose an image onto another at specified offset and using specified algorithm.
You can use this function for example to add a watermark image.

Examples

Compose a picture on second:

# load images...
Set Variable [ $Image1 ; Value: MBS( "GMImage.NewFromFile"; "/Users/cs/Pictures/IMG_3625.jpg") ]
Set Variable [ $Image2 ; Value: MBS( "GMImage.NewFromFile"; "/Users/cs/Pictures/mond.jpg") ]
# put first on second
Set Variable [ $r ; Value: MBS( "GMImage.CompositeXY"; $Image2; $Image1; 500; 200) ]
# and save to file
Set Variable [ $r ; Value: MBS( "GMImage.WriteToFile"; $Image2; "/Users/cs/Pictures/output.jpg") ]
# free memory
Set Variable [ $r ; Value: MBS( "GMImage.Release"; $Image1) ]
Set Variable [ $r ; Value: MBS( "GMImage.Release"; $Image2) ]

Compose transparent picture on top of white background:

# Load from container
Set Variable [ $BigImageRef ; Value: MBS("GMImage.NewFromContainer"; Test::BigImage) ]
# make new picture
Set Variable [ $NewImageRef ; Value: MBS("GMImage.New"; MBS("GMImage.GetWidth"; $BigImageRef) & "x" & MBS("GMImage.GetHeight"; $BigImageRef); "white") ]
# and compose
Set Variable [ $r ; Value: MBS( "GMImage.CompositeXY"; $NewImageRef; $BigImageRef; 0; 0; 1 /* over */) ]
# Store output and release the image
Set Field [ Test::Result ; MBS( "GMImage.WriteToJPEGContainer"; $NewImageRef ) ]
Set Variable [ $Error ; Value: MBS("GMImage.Free";$BigImageRef) ]
Set Variable [ $Error ; Value: MBS("GMImage.Free";$NewImageRef) ]

See also

Example Databases

Blog Entries

Created 18th August 2014, last changed 28th August 2022


GMImage.Composite - GMImage.Contrast

Feedback: Report problem or ask question.


Start Chat