GMImage.AutoOrient
------------------

Orient image to be right-side up based on its current orientation attribute.

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

MBS( "GMImage.AutoOrient"; ImageRef ) 

**MBS**( **"GMImage.AutoOrient";** /\* Orient image to be right-side up based on its current orientation attribute. \*/  
**$ImageRef**) /\* The image reference number.e.g. 1 \*/ 

### Parameters

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

### Result

Returns OK or error.

### Description

Orient image to be right-side up based on its current orientation attribute.  
This allows the image to be viewed correctly when the orientation attribute is not available, or is not respected.  
### Examples

Try it:

 # load image   
Set Variable \[ $Image ; Value: MBS ( "[GMImage.NewFromContainer](GMImageNewFromContainer.md)"; Correct Image Orientation::Input ) \]   
If \[ MBS ("IsError") = 0 \]   
 #   
 Set Variable \[ $r ; Value: MBS ( "GMImage.AutoOrient"; $Image ) \]   
 #   
 # Write back to new field  
 Set Field \[ Correct Image Orientation::Output ; MBS ( "[GMImage.WriteToJPEGContainer](GMImageWriteToJPEGContainer.md)"; $Image ; GetAsText(Correct Image Orientation::Input )) \]   
 #   
 # free memory  
 Set Variable \[ $r ; Value: MBS ( "[GMImage.Free](GMImageFree.md)"; $Image ) \]   
End If  
### See also

- [GMImage.Free](GMImageFree.md)
- [GMImage.New](GMImageNew.md)
- [GMImage.NewFromContainer](GMImageNewFromContainer.md)
- [GMImage.SetOrientation](GMImageSetOrientation.md)
- [GMImage.WriteToJPEGContainer](GMImageWriteToJPEGContainer.md)
- [IsError](IsError.md)

### Release notes

- **Version 9.0**
    - Added [GMImage.AutoOrient](http://www.mbsplugins.eu/GMImageAutoOrient.shtml), [GMImage.Extent](http://www.mbsplugins.eu/GMImageExtent.shtml), [GMImage.GetQuiet](http://www.mbsplugins.eu/GMImageGetQuiet.shtml), [GMImage.Repage](http://www.mbsplugins.eu/GMImageRepage.shtml), [GMImage.Resize](http://www.mbsplugins.eu/GMImageResize.shtml) and [GMImage.SetQuiet](http://www.mbsplugins.eu/GMImageSetQuiet.shtml) functions.

### Blog Entries

- [MBS FileMaker Plugin, version 9.0pr6](https://www.mbsplugins.de/archive/2019-01-02/MBS_FileMaker_Plugin_version_9/monkeybreadsoftware_blog_filemaker)
- [Correct Image Orientation in FileMaker](https://www.mbsplugins.de/archive/2018-11-09/Correct_Image_Orientation_in_F/monkeybreadsoftware_blog_filemaker)

This function checks for a license.

Created 28th December 2018 , last changed 21st February 2023

  
[GMImage.Annotate](GMImageAnnotate.md) - [GMImage.AveragePixelValue](GMImageAveragePixelValue.md)

[HTML Version](GMImageAutoOrient.shtml)