GMImage.Rotate
--------------

Rotate image by specified number of degrees.

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

MBS( "GMImage.Rotate"; ImageRef; degrees ) 

**MBS**( **"GMImage.Rotate";** /\* Rotate image by specified number of degrees. \*/  
**$ImageRef**; /\* The image reference number.e.g. 1 \*/   
**$degrees**) /\* The angle in degrees.e.g. 90 \*/ 

### Parameters

| Parameter | Description | Example |
|---|---|---|
| ImageRef | The image reference number. | 1 |
| degrees | The angle in degrees. | 90 |

### Result

Returns "OK" on success.

### Description

Rotate image by specified number of degrees.  
Positive angles rotate the image in a clockwise direction while negative angles rotate counter-clockwise.  
### Examples

Rotates image by 90 degree to right

 Let (   
\[   
$Image = MBS ("[GMImage.NewFromContainer](GMImageNewFromContainer.md)"; GraphicsMagick::image );   
$RotateResult = MBS ("GMImage.Rotate"; $Image ; 90);   
$Result = MBS ("[GMImage.WriteToPNGContainer](GMImageWriteToPNGContainer.md)"; $Image );   
$DestroyResult = MBS ("[GMImage.Release](GMImageRelease.md)";$Image )  
\];   
$Result )  
Custom function to rotate image:

 Let (   
/\*  
MBS\_Image\_Rotate (Picture; rotation)  
  
Picture: Container 'MyTable::MyField "  
rotation: Grad ° - numeric Value, positiv OR negative  
  
Benjamin Fehr, EfficientBizz GmbH  
http://www.efficientbizz.com   
\*/  
  
\[   
$Image = MBS ("[GMImage.NewFromContainer](GMImageNewFromContainer.md)"; Picture);   
$RotateResult = MBS ("GMImage.Rotate"; $Image ; rotation);   
$Result = MBS ("[GMImage.WriteToPNGContainer](GMImageWriteToPNGContainer.md)"; $Image );   
$DestroyResult = MBS ("[GMImage.Release](GMImageRelease.md)";$Image )  
\];   
  
$Result )  
Rotate with script and error checking:

 # Read image into variable   
Set Variable \[ $image ; Value: LiveStream::Image \]   
If \[ IsEmpty ( $image ) \]   
 # nothing to do  
 Exit Script \[ Text Result: \]   
End If  
  
\# load image   
Set Variable \[ $ImageRef ; Value: MBS ("[GMImage.NewFromContainer](GMImageNewFromContainer.md)"; $image ) \]   
If \[ MBS ("IsError") \]   
 Show Custom Dialog \[ "Failed to load image." ; $ImageRef \]   
 Exit Script \[ Text Result: \]   
End If  
  
\# rotate it   
Set Variable \[ $RotationResult ; Value: MBS ("GMImage.Rotate"; $ImageRef ; 90) \]   
If \[ MBS ("IsError") \]   
 Set Variable \[ $r ; Value: MBS ("[GMImage.Release](GMImageRelease.md)";$ImageRef ) \]   
 Show Custom Dialog \[ "Failed to rotate image." ; $RotationResult \]   
 Exit Script \[ Text Result: \]   
End If  
  
\# write back   
Set Variable \[ $NewImage ; Value: MBS ("[GMImage.WriteToPNGContainer](GMImageWriteToPNGContainer.md)"; $ImageRef ) \]   
If \[ MBS ("IsError") \]   
 Set Variable \[ $r ; Value: MBS ("[GMImage.Release](GMImageRelease.md)";$ImageRef ) \]   
 Show Custom Dialog \[ "Failed to rotate image." ; $NewImage \]   
 Exit Script \[ Text Result: \]   
End If  
  
\# if not error, put it back to record   
Set Field \[ LiveStream::Image ; $NewImage \]   
Set Variable \[ $r ; Value: MBS ("[GMImage.Release](GMImageRelease.md)";$ImageRef ) \]  
### See also

- [GMImage.Modulate](GMImageModulate.md)
- [GMImage.NewFromContainer](GMImageNewFromContainer.md)
- [GMImage.Release](GMImageRelease.md)
- [GMImage.Repage](GMImageRepage.md)
- [GMImage.Resize](GMImageResize.md)
- [GMImage.Rotating](GMImageRotating.md)
- [GMImage.SetMatte](GMImageSetMatte.md)
- [GMImage.SetPage](GMImageSetPage.md)
- [GMImage.WriteToPNGContainer](GMImageWriteToPNGContainer.md)
- [IsError](IsError.md)

### Example Databases

- [GraphicsMagick/Correct Image Orientation](https://www.mbsplugins.eu/MBS-FileMaker-Plugin-Examples/GraphicsMagick/Correct%20Image%20Orientation.shtml#1ScriptAnchor_)
- [GraphicsMagick/GraphicsMagick Sample](https://www.mbsplugins.eu/MBS-FileMaker-Plugin-Examples/GraphicsMagick/GraphicsMagick%20Sample.shtml#4ScriptAnchor_)

### Blog Entries

- [MBS Plugin Advent calendar: 16 - GraphicsMagick](https://www.mbsplugins.de/archive/2023-12-16/MBS_Plugin_Advent_calendar_16_/monkeybreadsoftware_blog_filemaker)
- [GraphicsMagick in FileMaker, part 6](https://www.mbsplugins.de/archive/2022-12-06/GraphicsMagick_in_FileMaker_pa/monkeybreadsoftware_blog_filemaker)
- [Correct Image Orientation in FileMaker](https://www.mbsplugins.de/archive/2018-11-09/Correct_Image_Orientation_in_F/monkeybreadsoftware_blog_filemaker)

### FileMaker Magazin

- [Ausgabe 2/2023, Seite 28](https://filemaker-magazin.de/neuigkeit/4223-Appetithappen-FMM_202302)

This function checks for a license.

Created 18th August 2014 , last changed 24th February 2026

  
[GMImage.Rollxy](GMImageRollxy.md) - [GMImage.Rotating](GMImageRotating.md)

[HTML Version](GMImageRotate.shtml)