GMImage.Compare
---------------

Compares current image with another image.

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

MBS( "GMImage.Compare"; ImageRef; OtherImageRef ) 

**MBS**( **"GMImage.Compare";** /\* Compares current image with another image. \*/  
**$ImageRef**; /\* The image reference number.e.g. 1 \*/   
**$OtherImageRef**) /\* The image reference number.e.g. 1 \*/ 

### Parameters

| Parameter | Description | Example |
|---|---|---|
| ImageRef | The image reference number. | 1 |
| OtherImageRef | The image reference number. | 1 |

### Result

Returns true if equal and false if not equal.

### Description

Compares current image with another image.  
Sets meanErrorPerPixel, normalizedMaxError, and normalizedMeanError in the current image. False is returned if the images are identical.  
### Examples

Compare images:

 Set Variable \[$img1 ; Value:MBS ( "[GMImage.NewFromContainer](GMImageNewFromContainer.md)"; test::Container1 )\]  
Set Variable \[$img2 ; Value:MBS ( "[GMImage.NewFromContainer](GMImageNewFromContainer.md)"; test::Container2 )\]  
Set Variable \[$result ; Value:MBS ( "GMImage.Compare"; $img1 ; $img2 )\]  
If \[$result = 1\]  
 Show Custom Dialog \["Image Comparison"; "equal"\]  
Else If \[$result = 0\]  
 Set Variable \[$e ; Value:MBS ( "[GMImage.NormalizedMaxError](GMImageNormalizedMaxError.md)"; $img1 )\]  
 If \[$e ≠ 0 and $e &lt; ,03\]  
 Show Custom Dialog \["Image Comparison"; "very similar: " &amp; MBS ( "[GMImage.NormalizedMaxError](GMImageNormalizedMaxError.md)"; $img1 )\]  
 Else  
 Show Custom Dialog \["Image Comparison"; "not equal"\]  
 End If  
End If  
Set Variable \[$r ; Value:MBS ("[GMImage.Release](GMImageRelease.md)"; $img1 )\]  
Set Variable \[$r ; Value:MBS ("[GMImage.Release](GMImageRelease.md)"; $img2 )\]  
### See also

- [GMImage.Coders](GMImageCoders.md)
- [GMImage.Composite](GMImageComposite.md)
- [GMImage.New](GMImageNew.md)
- [GMImage.NewFromContainer](GMImageNewFromContainer.md)
- [GMImage.Normalize](GMImageNormalize.md)
- [GMImage.NormalizedMaxError](GMImageNormalizedMaxError.md)
- [GMImage.Release](GMImageRelease.md)
- [GMImage.Repage](GMImageRepage.md)
- [GMImage.Rotate](GMImageRotate.md)
- [GMImage.Sample](GMImageSample.md)

This function checks for a license.

Created 18th August 2014 , last changed 21st December 2018

  
[GMImage.Columns](GMImageColumns.md) - [GMImage.Composite](GMImageComposite.md)

[HTML Version](GMImageCompare.shtml)