GMImage.GetPixelColor
---------------------

Get pixel color at location x &amp; y.

| Component | Version | macOS | Windows | Linux | Server | iOS SDK |
|---|---|---|---|---|---|---|
| [GraphicsMagick](component_GraphicsMagick.md) | [2.0](newinversion20.md) | ✅ Yes | ✅ Yes | ✅ Yes | ✅ Yes | ✅ Yes |

MBS( "GMImage.GetPixelColor"; ImageRef; X; Y ) 

**MBS**( **"GMImage.GetPixelColor";** /\* Get pixel color at location x &amp; y. \*/  
**$ImageRef**; /\* The image reference number.e.g. 1 \*/   
**$X**; /\* The horizontal position. Range from 0 to [GMImage.GetWidth](GMImageGetWidth.md)-1.e.g. 0 \*/   
**$Y**) /\* The vertical position. Range from 0 to [GMImage.GetHeight](GMImageGetHeight.md)-1.e.g. 0 \*/ 

### Parameters

| Parameter | Description | Example |
|---|---|---|
| ImageRef | The image reference number. | 1 |
| X | The horizontal position. Range from 0 to [GMImage.GetWidth](GMImageGetWidth.md)-1. | 0 |
| Y | The vertical position. Range from 0 to [GMImage.GetHeight](GMImageGetHeight.md)-1. | 0 |

### Result

Returns a color value as string.

### Description

Get pixel color at location x &amp; y.  
Returned color is 16bit in v9.0 or later.  
You may need to divide values by 257 if you need 8 bit values.  
### Examples

Open picture and read first pixel:

 Let ( \[   
  
$Image = MBS ("[GMImage.NewFromContainer](GMImageNewFromContainer.md)"; GraphicsMagick::image );   
$colorValue = MBS ("GMImage.GetPixelColor"; $Image ; 0; 0);   
$Error = MBS ("[GMImage.Release](GMImageRelease.md)";$Image )  
\];   
  
$colorValue )  
Trims space around image and make transparent:

 Set Variable \[$BigImageRef ; Value:MBS ("[GMImage.NewFromContainer](GMImageNewFromContainer.md)"; Test::BigImage )\]  
Set Variable \[$Result ; Value:MBS ( "[GMImage.SetBackgroundColor](GMImageSetBackgroundColor.md)"; $BigImageRef ; "RGB 1 0 0" )\]  
Set Variable \[$Result ; Value:MBS ("[GMImage.Trim](GMImageTrim.md)"; $BigImageRef )\]  
Set Variable \[$Result ; Value:MBS ( "[GMImage.SetColorFuzz](GMImageSetColorFuzz.md)"; $BigImageRef ; 5 )\]  
Set Variable \[$Result ; Value:MBS ( "[GMImage.SetMatte](GMImageSetMatte.md)"; $BigImageRef ; 1 )\]  
Set Variable \[$farbe ; Value:MBS ( "GMImage.GetPixelColor"; $BigImageRef ; 0; 0 )\]  
Set Variable \[$Result ; Value:MBS ( "[GMImage.ReplaceColor](GMImageReplaceColor.md)"; $BigImageRef ; $farbe ; "RGB 1 1 1 1"; 5)\]  
Set Field \[Test::Result ; MBS ( "[GMImage.WriteToPNGContainer](GMImageWriteToPNGContainer.md)"; $BigImageRef )\]  
Set Variable \[$Error ; Value:MBS ("[GMImage.Release](GMImageRelease.md)";$BigImageRef )\]  
### See also

- [GMImage.GetBorderColor](GMImageGetBorderColor.md)
- [GMImage.GetBoxColor](GMImageGetBoxColor.md)
- [GMImage.GetFillColor](GMImageGetFillColor.md)
- [GMImage.GetStrokeColor](GMImageGetStrokeColor.md)
- [GMImage.SetBackgroundColor](GMImageSetBackgroundColor.md)
- [GMImage.SetBoxColor](GMImageSetBoxColor.md)
- [GMImage.SetFillColor](GMImageSetFillColor.md)
- [GMImage.SetMatteColor](GMImageSetMatteColor.md)
- [GMImage.SetPixelColor](GMImageSetPixelColor.md)
- [GMImage.Trim](GMImageTrim.md)

### Example Databases

- [GraphicsMagick/Find Pixels](https://www.mbsplugins.eu/MBS-FileMaker-Plugin-Examples/GraphicsMagick/Find%20Pixels.shtml#1ScriptAnchor_)
- [GraphicsMagick/Pick color from image via Screenshot](https://www.mbsplugins.eu/MBS-FileMaker-Plugin-Examples/GraphicsMagick/Pick%20color%20from%20image%20via%20Screenshot.shtml#1ScriptAnchor_)
- [GraphicsMagick/Trim Picture](https://www.mbsplugins.eu/MBS-FileMaker-Plugin-Examples/GraphicsMagick/Trim%20Picture.shtml#4ScriptAnchor_)

### Blog Entries

- [MBS FileMaker Plugin, version 5.1pr1](https://www.mbsplugins.de/archive/2015-03-16/MBS_FileMaker_Plugin_version_5/monkeybreadsoftware_blog_filemaker)

This function checks for a license.

Created 18th August 2014 , last changed 9th January 2020

  
[GMImage.GetPage](GMImageGetPage.md) - [GMImage.GetProfile](GMImageGetProfile.md)

[HTML Version](GMImageGetPixelColor.shtml)