GMImage.ReadContainer
---------------------

Read single image frame into current object.

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

MBS( "GMImage.ReadContainer"; ImageRef; Data { ; Geometry; Depth; Magick } ) 

**MBS**( **"GMImage.ReadContainer";** /\* Read single image frame into current object. \*/  
**$ImageRef**; /\* The image reference number.e.g. 1 \*/   
**$Data**; /\* The container value, either a variable or a container field. \*/   
**$Geometry**; /\* Optional; The rectangle.   
Geometry is specified as a width and height "100x200".   
Can be empty. \*/   
**$Depth**; /\* Optional; Color depth parameter.e.g. 0 \*/   
**$Magick**) /\* Optional; The codec to use to read file. \*/ 

(old name: GMImage.ReadFromContainer)

### Parameters

| Parameter | Description | Example | Flags |
|---|---|---|---|
| ImageRef | The image reference number. | 1 |  |
| Data | The container value, either a variable or a container field. |  |  |
| Geometry | The rectangle.    Geometry is specified as a width and height "100x200".    Can be empty. |  | Optional |
| Depth | Color depth parameter. | 0 | Optional |
| Magick | The codec to use to read file. |  | Optional |

### Result

Returns OK or error.

### Description

Read single image frame into current object.  
This allows you to set options before reading in image.  
  
You may want to use [GMImage.SetBackgroundColor](GMImageSetBackgroundColor.md), [GMImage.SetMagick](GMImageSetMagick.md), [GMImage.SetFileName](GMImageSetFileName.md) or other settings before calling this.  
### Examples

Convert a SVG image to PNG with alpha channel:

 # Load image from container   
Set Variable \[ $image ; Value: MBS ( "[GMImage.New](GMImageNew.md)"; "500x500"; "transparent" ) \]   
\# turn on alpha channel and set background to transparent   
Set Variable \[ $r ; Value: MBS ( "[GMImage.SetType](GMImageSetType.md)"; $image ; 7 ) \]   
Set Variable \[ $r ; Value: MBS ( "[GMImage.SetBackgroundColor](GMImageSetBackgroundColor.md)"; $Image ; "transparent" ) \]   
\# read SVG   
Set Variable \[ $r ; Value: MBS ( "GMImage.ReadContainer"; $image ; SVG to PNG::InputFile ; "500x500"; 0; "SVG" ) \]   
\# Output to container and release image   
Set Field \[ SVG to PNG::OutputFile ; MBS ( "[GMImage.WriteToPNGContainer](GMImageWriteToPNGContainer.md)"; $image ; "test.png") \]   
Set Variable \[ $r ; Value: MBS ("[GMImage.Free](GMImageFree.md)"; $image ) \]  
Try GraphicsMagick in file WMF or EMF Conversion

 Set Variable \[ $image ; Value: MBS ( "[GMImage.New](GMImageNew.md)"; "300x300"; "white" ) \]   
Set Variable \[ $r ; Value: MBS ( "[GMImage.SetMagick](GMImageSetMagick.md)"; $image ; "EMF") \]   
Set Variable \[ $r ; Value: MBS ( "GMImage.ReadContainer"; $Image ; WMF Conversion::Input WMF) \]   
If \[ MBS ("IsError") \]   
 Show Custom Dialog \[ "Error" ; $r \]   
Else  
 Set Field \[ WMF Conversion::Output PNG ; MBS ( "[GMImage.WriteToPNGContainer](GMImageWriteToPNGContainer.md)"; $image ) \]   
 Set Variable \[ $r ; Value: MBS ("[GMImage.Release](GMImageRelease.md)"; $image ) \]   
End If  
### See also

- [GMImage.Free](GMImageFree.md)
- [GMImage.New](GMImageNew.md)
- [GMImage.NewFromContainer](GMImageNewFromContainer.md)
- [GMImage.PingContainer](GMImagePingContainer.md)
- [GMImage.SetBackgroundColor](GMImageSetBackgroundColor.md)
- [GMImage.SetFileName](GMImageSetFileName.md)
- [GMImage.SetMagick](GMImageSetMagick.md)
- [GMImage.SetType](GMImageSetType.md)
- [GMImage.WriteToContainer](GMImageWriteToContainer.md)
- [GMImage.WriteToPNGContainer](GMImageWriteToPNGContainer.md)

### Release notes

- **Version 14.4**
    - Improved [GMImage.ReadContainer](https://www.mbsplugins.eu/GMImageReadContainer.shtml) to better pick decoder based on file name.

### Example Databases

- [DynaPDF/WMF Conversion](https://www.mbsplugins.eu/MBS-FileMaker-Plugin-Examples/DynaPDF/WMF%20Conversion.shtml#5ScriptAnchor_)
- [GraphicsMagick/SVG to PNG](https://www.mbsplugins.eu/MBS-FileMaker-Plugin-Examples/GraphicsMagick/SVG%20to%20PNG.shtml#1ScriptAnchor_)

### Blog Entries

- [MBS FileMaker Plugin, version 14.4pr3](https://www.mbsplugins.de/archive/2024-08-21/MBS_FileMaker_Plugin_version_1/monkeybreadsoftware_blog_filemaker)
- [News about the MBS FileMaker Plugin 10.2](https://www.mbsplugins.de/archive/2020-05-19/News_about_the_MBS_FileMaker_P/monkeybreadsoftware_blog_filemaker)
- [MBS FileMaker Plugin, version 10.2pr3](https://www.mbsplugins.de/archive/2020-04-14/MBS_FileMaker_Plugin_version_1/monkeybreadsoftware_blog_filemaker)
- [Convert a SVG image to PNG with alpha channel](https://www.mbsplugins.de/archive/2020-04-07/Convert_a_SVG_image_to_PNG_wit/monkeybreadsoftware_blog_filemaker)

This function checks for a license.

Created 7th April 2020 , last changed 22nd April 2025

  
[GMImage.Read](GMImageRead.md) - [GMImage.ReduceNoise](GMImageReduceNoise.md)

[HTML Version](GMImageReadContainer.shtml)