GMImage.Border
--------------

Border image (add border to image).

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

MBS( "GMImage.Border"; ImageRef { ; Geometry } ) 

**MBS**( **"GMImage.Border";** /\* Border image (add border to image). \*/  
**$ImageRef**; /\* The image reference number.e.g. 1 \*/   
**$Geometry**) /\* Optional; Optional, The rectangle with border width and height. Geometry is specified as a width and height "100x200".e.g. "100x200" \*/ 

### Parameters

| Parameter | Description | Example | Flags |
|---|---|---|---|
| ImageRef | The image reference number. | 1 |  |
| Geometry | Optional, The rectangle with border width and height. Geometry is specified as a width and height "100x200". | "100x200" | Optional |

### Result

Returns "OK" on success.

### Description

Border image (add border to image).   
The color of the border is specified by the borderColor attribute.  
Offset from geometry is not used, just width and height.  
### Examples

Add whitespace on top and bottom of image:

 Let ( \[   
  
$Image = MBS ("[GMImage.NewFromContainer](GMImageNewFromContainer.md)"; GraphicsMagick::image );   
$r = MBS ( "[GMImage.SetBorderColor](GMImageSetBorderColor.md)"; $Image ; "white" );  
$r = MBS ("GMImage.Border";$Image ; "0x100");   
$Result = MBS ("[GMImage.WriteToPNGContainer](GMImageWriteToPNGContainer.md)"; $Image );   
  
$r = MBS ("[GMImage.Release](GMImageRelease.md)";$Image )  
\];   
  
$Result )  
Add white space:

 Set Variable \[ $image ; Value: MBS ("[GMImage.NewFromContainer](GMImageNewFromContainer.md)"; ScancodeTests::MyImage ) \]   
Set Variable \[ $r ; Value: MBS ("[GMImage.SetBorderColor](GMImageSetBorderColor.md)"; $image ; "white") \]   
Set Variable \[ $r ; Value: MBS ("GMImage.Border"; $image ; "20x2") \]  
Scale image down, add border and crop:

 # Load from container   
Set Variable \[ $Image ; Value: MBS ("[GMImage.NewFromContainer](GMImageNewFromContainer.md)"; Image Scaling::InputImage ) \]   
\#   
\# Scale the image by the size needed   
Set Variable \[ $r ; Value: MBS ("[GMImage.Scale](GMImageScale.md)";$Image ; "80x200") \]   
\#   
\# calculate border to add   
Set Variable \[ $w ; Value: Round ( (80 - MBS ("[GMImage.GetWidth](GMImageGetWidth.md)";$Image )) / 2 ; 0 ) \]   
Set Variable \[ $h ; Value: Round ( (200 - MBS ("[GMImage.GetHeight](GMImageGetHeight.md)";$Image )) / 2 ; 0 ) \]   
Set Variable \[ $r ; Value: MBS ("[GMImage.SetBorderColor](GMImageSetBorderColor.md)";$Image ; "white") \]   
Set Variable \[ $r ; Value: MBS ("GMImage.Border";$Image ; $w &amp; "x" &amp; $h ) \]   
\#   
\# cut to make sure we are not off by one extra pixel   
Set Variable \[ $r ; Value: MBS ("[GMImage.Crop](GMImageCrop.md)";$Image ; "80x200") \]   
\#   
\# Write image to container and set the Information text   
Set Field \[ Image Scaling::Result ; MBS ("[GMImage.WriteToPNGContainer](GMImageWriteToPNGContainer.md)"; $Image ) \]   
Set Variable \[ $r ; Value: MBS ("[GMImage.Free](GMImageFree.md)";$Image ) \]  
### See also

- [GMImage.Coders](GMImageCoders.md)
- [GMImage.Crop](GMImageCrop.md)
- [GMImage.Format](GMImageFormat.md)
- [GMImage.Free](GMImageFree.md)
- [GMImage.New](GMImageNew.md)
- [GMImage.NewFromContainer](GMImageNewFromContainer.md)
- [GMImage.Release](GMImageRelease.md)
- [GMImage.Scale](GMImageScale.md)
- [GMImage.SetBorderColor](GMImageSetBorderColor.md)
- [GMImage.WriteToPNGContainer](GMImageWriteToPNGContainer.md)

### Blog Entries

- [GraphicsMagick in FileMaker, part 4](https://www.mbsplugins.de/archive/2022-12-04/GraphicsMagick_in_FileMaker_pa/monkeybreadsoftware_blog_filemaker)

This function checks for a license.

Created 18th August 2014 , last changed 27th August 2022

  
[GMImage.BlurChannel](GMImageBlurChannel.md) - [GMImage.BoundingBox](GMImageBoundingBox.md)

[HTML Version](GMImageBorder.shtml)