GMImage.Affine
--------------

Applies an affine transformation.

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

MBS( "GMImage.Affine"; ImageRef { ; sx; sy; rx; ry; tx; ty } ) 

**MBS**( **"GMImage.Affine";** /\* Applies an affine transformation. \*/  
**$ImageRef**; /\* The image reference number.e.g. 1 \*/   
**$sx**; /\* Optional; The x scale factors.  
Default is 1.e.g. 1 \*/   
**$sy**; /\* Optional; The y scale factors.  
Default is 1.e.g. 1 \*/   
**$rx**; /\* Optional; The x rotate factors.e.g. 0 \*/   
**$ry**; /\* Optional; The y rotate factors.e.g. 0 \*/   
**$tx**; /\* Optional; The x translation value.e.g. 0 \*/   
**$ty**) /\* Optional; The y translation value.e.g. 0 \*/ 

### Parameters

| Parameter | Description | Example | Flags |
|---|---|---|---|
| ImageRef | The image reference number. | 1 |  |
| sx | The x scale factors.   Default is 1. | 1 | Optional |
| sy | The y scale factors.   Default is 1. | 1 | Optional |
| rx | The x rotate factors. | 0 | Optional |
| ry | The y rotate factors. | 0 | Optional |
| tx | The x translation value. | 0 | Optional |
| ty | The y translation value. | 0 | Optional |

### Result

Returns OK or error.

### Description

Applies an affine transformation.  
Specify a transformation matrix to adjust scaling, rotation, and translation (coordinate transformation) for subsequently drawn objects in the same or decendent drawing context. The sx &amp; sy parameters represent the x &amp; y scale factors, the rx &amp; ry parameters represent the x &amp; y rotation, and the tx &amp; ty parameters represent the x &amp; y translation:  
### Examples

Make the image double the width:

 Set Variable \[ $r ; Value: MBS ( "[GMImage.AffineTransform](GMImageAffineTransform.md)"; $Image ; 2; 1; 0; 0; 0; 0 ) \]  
Make the image double the height:

 Set Variable \[ $r ; Value: MBS ( "[GMImage.AffineTransform](GMImageAffineTransform.md)"; $Image ; 1; 2; 0; 0; 0; 0 ) \]  
Rotate 10 degree:

 Set Variable \[ $r ; Value: MBS ( "[GMImage.AffineTransform](GMImageAffineTransform.md)"; $Image ; 1; 1; 10/180\*Pi; -10/180\*Pi; 0; 0 ) \]  
Move 100 points to left:

 Set Variable \[ $r ; Value: MBS ( "[GMImage.AffineTransform](GMImageAffineTransform.md)"; $Image ; 1; 1; 0; 0; 100; 0 ) \]  
### See also

- [GMImage.AffineTransform](GMImageAffineTransform.md)
- [GMImage.Resize](GMImageResize.md)

### Release notes

- **Version 16.2**
    - Added [GMImage.AffineTransform](https://www.mbsplugins.eu/GMImageAffineTransform.shtml) function.

This function checks for a license.

Created 18th August 2014 , last changed 30th March 2026

  
[GMImage.AddPathSmoothQuadraticCurvetoRel](GMImageAddPathSmoothQuadraticCurvetoRel.md) - [GMImage.AffineTransform](GMImageAffineTransform.md)

[HTML Version](GMImageAffine.shtml)