« CallKit extension for… | Home | Bluetooth LE on Windo… »

GraphicsMagick in FileMaker, part 16

🎄
16 of 24

Welcome to the 16th door of our advent calendar. In this advent calendar I would like to take you on a journey through the GraphicsMagick component in December. Every day I will introduce you to one or more functions from this component. In this component you will find functions with which you can analyze images, convert them, change them with filters, draw them and much much more. In the end, you too can take the magic of GraphicsMagick to your images. I wish you a lot of fun in the process.

Today I'll introduce you to the GMImage.Channel function that allows us to extract individual channels from an image. We have already seen in some effects that we can use individual channels, whether we want to apply blur or if we want to give the image a noise with red pixels. Channels are a great thing. Let's take a closer look at them. In the function GMImage.Channel we first specify the reference in the parameters and then the ChannelType. Each channel type is assigned a number which must be specified in the parameters. Here we see a list of channels that are available to us:

  • RedChannel = 1
  • CyanChannel = 2
  • GreenChannel = 3
  • MagentaChannel = 4
  • BlueChannel = 5
  • YellowChannel = 6
  • OpacityChannel = 7
  • BlackChannel = 8
  • MatteChannel = 9
  • AllChannels = 10
  • GrayChannel = 11

Channels 1,3 and 5 belong to the RGB color space, so that we can successfully apply the GMImage.Channel function to the images, they must be in the RGB color space or first converted with GMImage.SetColorSpace.

Variable setzen [ $r ; Wert: MBS("GMImage.SetColorSpace"; $GM; 1) ] 
Variable setzen [ $r ; Wert: MBS( "GMImage.Channel"; $GM; 3 ) ] 
Here you can see our logo in the individual RGB channels

Original

Red (1)

Green (3)

Blue (5)

Conversion to the correct color space is needed for the CMYK color space for channels 2,4,6 and 8.

Variable setzen [ $r ; Wert: MBS("GMImage.SetColorSpace"; $GM; 10) ] 
Variable setzen [ $r ; Wert: MBS( "GMImage.Channel"; $GM; 11 ) ] 

Cyan (2)

Magenta (4)

Yellow (6)

Black (8)

If we apply the function to our logo image with the red background with an OpacityChannel or MatteChannel (old version) then we get a completely black image because we have no pixels that have transparency. Here you can see a different image that has a gradation of the color red in opacity of 20, 40, 60, 80 and 100.

Let's extract the Opacity Channel here. We see the more opacity the darker the color is interpreted. For example, if we have our logo in full opacity and we have a transparent background then our logo will be a black circle after applying the function. Everything that is transparent remains white.

Last but not least we have the image results of AllChannels which is a simple grayscale image.

and GrayChannels here the colors represent the intensity of the colors

Tomorrow will be colorful. Until then, perhaps enjoy the Advent day with a cup of tea and a cookie.

Previous day   Next day

16 12 22 - 13:20