GMImage.FindColorInRow
----------------------

Locates first pixel in the row with given color.

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

MBS( "GMImage.FindColorInRow"; ImageRef; X; Y; Color { ; Invert; Tolerance } ) 

**MBS**( **"GMImage.FindColorInRow";** /\* Locates first pixel in the row with given color. \*/  
**$ImageRef**; /\* The image reference number.e.g. 1 \*/   
**$X**; /\* The x coordinate. Zero based from 0 to [GMImage.GetWidth](GMImageGetWidth.md)-1.e.g. 10 \*/   
**$Y**; /\* The y coordinate. Zero based from 0 to [GMImage.GetHeight](GMImageGetHeight.md)-1.e.g. 10 \*/   
**$Color**; /\* A color value.   
This can be a string in the following format "HSL h s l a", "YUV y u v a", "RGB r g b a", "MONO m a", "GRAY g a" or "COLOR R G B a". Alpha value a is optional. Range of values is 0 to 1.0 except if you use COLOR where RGB values are 0 to 65535.  
Starting with version 5.4 of our plugin, you can use hex notation. # followed by 2 digits for red, green, blue and optional alpha, e.g. #FF0000 for full red.e.g. "RGB 1 0 0" \*/   
**$Invert**; /\* Optional; If 0, we find first pixel matching your color. If 1 we find first pixel not matching the color. Default is 0.e.g. 0 \*/   
**$Tolerance**) /\* Optional; The tolerance for comparison. Normally a small value like 3. So if color is 65535, 65535, 65535 and pixel is 64764, 64764, 64764 we have a match for tolerance being 800.e.g. 800 \*/ 

### Parameters

| Parameter | Description | Example | Flags |
|---|---|---|---|
| ImageRef | The image reference number. | 1 |  |
| X | The x coordinate. Zero based from 0 to [GMImage.GetWidth](GMImageGetWidth.md)-1. | 10 |  |
| Y | The y coordinate. Zero based from 0 to [GMImage.GetHeight](GMImageGetHeight.md)-1. | 10 |  |
| Color | A color value.    This can be a string in the following format "HSL h s l a", "YUV y u v a", "RGB r g b a", "MONO m a", "GRAY g a" or "COLOR R G B a". Alpha value a is optional. Range of values is 0 to 1.0 except if you use COLOR where RGB values are 0 to 65535.   Starting with version 5.4 of our plugin, you can use hex notation. # followed by 2 digits for red, green, blue and optional alpha, e.g. #FF0000 for full red. | "RGB 1 0 0" |  |
| Invert | If 0, we find first pixel matching your color. If 1 we find first pixel not matching the color. Default is 0. | 0 | Optional |
| Tolerance | The tolerance for comparison. Normally a small value like 3. So if color is 65535, 65535, 65535 and pixel is 64764, 64764, 64764 we have a match for tolerance being 800. | 800 | Optional |

### Result

Returns position or error.

### Description

Locates first pixel in the row with given color.  
You can find first pixel matching your given color in the row starting with given x position and given tolerance. If you set Invert to 1, the plugin returns column for first pixel not matching color.  
Returns -1 if not found.  
### Examples

Finds color in row:

 MBS ("GMImage.FindColorInRow"; $img ; $x ; $y ; $ColorToSearch ; 1; 3)  
### See also

- [GMImage.FindColorInColumn](GMImageFindColorInColumn.md)
- [GMImage.GetHeight](GMImageGetHeight.md)
- [GMImage.GetWidth](GMImageGetWidth.md)

### Example Databases

- [GraphicsMagick/Find Pixels](https://www.mbsplugins.eu/MBS-FileMaker-Plugin-Examples/GraphicsMagick/Find%20Pixels.shtml#1ScriptAnchor_)

### Blog Entries

- [MBS FileMaker Plugin, version 5.0pr10](https://www.mbsplugins.de/archive/2015-02-06/MBS_FileMaker_Plugin_version_5/monkeybreadsoftware_blog_filemaker)

This function checks for a license.

Created 4th February 2015 , last changed 11st November 2019

  
[GMImage.FindColorInColumn](GMImageFindColorInColumn.md) - [GMImage.Flatten](GMImageFlatten.md)

[HTML Version](GMImageFindColorInRow.shtml)