Components | All | New | MacOS | Windows | Linux | iOS | ||||
Examples | Mac & Win | Server | Client | Guides | Statistic | FMM | Blog | Deprecated | Old |
GMImage.CopyChannel
Copies one channel from one image into channel of other image.
Component | Version | macOS | Windows | Linux | Server | iOS SDK |
GraphicsMagick | 7.3 | ✅ Yes | ✅ Yes | ✅ Yes | ✅ Yes | ✅ Yes |
Parameters
Parameter | Description | Example |
---|---|---|
SourceImage | The image reference number of source image. | $sourceImage |
SourceChannel | The source channel. Can be Red, Green, Blue or Opacity. |
"Opacity" |
DestImage | The image reference number of dest image. | $destImage |
DestChannel | The dest channel. Can be Red, Green, Blue or Opacity. |
"Opacity" |
Result
Returns OK or error.
Description
Copies one channel from one image into channel of other image.e.g. to copy opacity from one image to other.
Examples
Clip an image:
Set Variable [ $gray ; Value: "#777777" ]
# Read in source image
Set Variable [ $SourceImage ; Value: MBS( "GMImage.NewFromContainer"; Clip Image::Input ) ]
Set Variable [ $sourceWidth ; Value: MBS( "GMImage.GetWidth"; $SourceImage) ]
Set Variable [ $sourceHeight ; Value: MBS( "GMImage.GetHeight"; $SourceImage) ]
#
# Scale to dest size
Set Variable [ $sourceSize ; Value: If($sourceWidth > $sourceHeight; $sourceHeight; $sourceWidth) ]
Set Variable [ $destWidth ; Value: GetAsNumber ( Clip Image::Width ) ]
Set Variable [ $destHeight ; Value: GetAsNumber ( Clip Image::Height ) ]
Set Variable [ $destSize ; Value: If($destWidth > $destHeight; $destHeight; $destWidth) ]
Set Variable [ $tempImage ; Value: MBS( "GMImage.New"; $sourceSize & "x" & $sourceSize; "transparent" ) ]
Set Variable [ $r ; Value: MBS( "GMImage.CompositeXY"; $tempImage; $sourceImage; -($sourceWidth-$sourceSize)/2; -($sourceHeight-$sourceSize)/2; 1) ]
Set Variable [ $r ; Value: MBS( "GMImage.Scale"; $tempImage; $destSize & "x" & $destSize ) ]
#
# Build mask
Set Variable [ $clipImage ; Value: MBS( "GMImage.New"; $destSize & "x" & $destSize; "transparent" ) ]
Set Variable [ $r ; Value: MBS( "GMImage.SetFillColor"; $clipImage; "black" ) ]
Set Variable [ $radius ; Value: $destSize/2 ]
Set Variable [ $r ; Value: MBS( "GMImage.DrawCircle"; $clipImage; $radius; $radius; 0; $radius ) ]
#
# Apply mask
Set Variable [ $r ; Value: MBS( "GMImage.CopyChannel"; $tempImage; "Opacity"; $clipImage; "Opacity") ]
#
# Create destination image
Set Variable [ $destImage ; Value: MBS( "GMImage.New"; $destWidth & "x" & $destHeight; $gray ) ]
Set Variable [ $r ; Value: MBS( "GMImage.CompositeXY"; $destImage; $tempImage; ($destWidth-$destSize)/2; ($destHeight-$destSize)/2; 1) ]
Set Field [ Clip Image::Output ; MBS( "GMImage.WriteToPNGContainer"; $destImage) ]
#
# Memory cleanup
Set Variable [ $r ; Value: MBS( "GMImage.Release"; $SourceImage) ]
Set Variable [ $r ; Value: MBS( "GMImage.Release"; $tempImage) ]
Set Variable [ $r ; Value: MBS( "GMImage.Release"; $clipImage) ]
See also
- GMImage.BlurChannel
- GMImage.DrawCircle
- GMImage.GetHeight
- GMImage.GetWidth
- GMImage.LevelChannel
- GMImage.New
- GMImage.NewFromContainer
- GMImage.Scale
- GMImage.SetFillColor
- GMImage.WriteToPNGContainer
Release notes
- Version 8.4
- Improved performance for GMImage.CopyChannel when copying within the same image.
- Version 8.2
- Fixed bug in GMImage.CopyChannel function.
- Version 7.3
- Added GMImage.CopyChannel function.
Example Databases
Blog Entries
- MBS FileMaker Plugin, version 8.4pr1
- MBS FileMaker Plugin, version 8.2pr2
- Circle crop images in FileMaker with MBS Plugin
FileMaker Magazin
This function checks for a license.
Created 16th July 2017, last changed 21st December 2018