GMImage.NewFromContainer
------------------------

Loads a picture from the given container.

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

MBS( "GMImage.NewFromContainer"; Data ) 

**MBS**( **"GMImage.NewFromContainer";** /\* Loads a picture from the given container. \*/  
**$Data**) /\* A value from a Container Field.  
Can include various image formats like JPEG, PNG or just containers with FILE data. \*/ 

### Parameters

| Parameter | Description | Example |
|---|---|---|
| Data | A value from a Container Field.   Can include various image formats like JPEG, PNG or just containers with FILE data. |  |

### Result

Returns the ImageRef number on success.

### Description

Loads a picture from the given container.  
Please call [GMImage.Release](GMImageRelease.md) later to free memory for this image.  
Image reference numbers are starting at 18000 and counting up for each new image.  
  
If image doesn't load, please check whether it's a HEIC, HEIF or RAW image. For those, please use [Container.ReadImage](ContainerReadImage.md) first to convert on macOS/iOS/Windows.  
  
When the container has a PDF, the plugin may just load the preview image. Please use [DynaPDF.RenderPage](DynaPDFRenderPage.md), [PDFKit.GetPDFPageImage](PDFKitGetPDFPageImage.md) or [WinPDF.PageImage](WinPDFPageImage.md) to render an image from the PDF first, before loading it.  
### Examples

Show with and height

 Let ( \[   
$Image = MBS ("GMImage.NewFromContainer"; GraphicsMagick::image );   
$Width = MBS ("[GMImage.GetWidth](GMImageGetWidth.md)";$Image );   
$Height = MBS ("[GMImage.GetHeight](GMImageGetHeight.md)";$Image );   
$Error = MBS ("[GMImage.Release](GMImageRelease.md)";$Image )  
\];   
$Width &amp; " x " &amp; $Height )  
Load from container:

 MBS ( "GMImage.NewFromContainer"; test::test )  
Invert image:

 Set Variable \[ $image ; Value: MBS ( "GMImage.NewFromContainer"; Invert::Input ) \]   
\# each channel...   
// Set Variable \[ $r ; Value: MBS ( "[GMImage.InvertChannel](GMImageInvertChannel.md)"; $image ; "red") \]   
// Set Variable \[ $r ; Value: MBS ( "[GMImage.InvertChannel](GMImageInvertChannel.md)"; $image ) \]   
// Set Variable \[ $r ; Value: MBS ( "[GMImage.InvertChannel](GMImageInvertChannel.md)"; $image ; "blue") \]   
\# all channels...   
Set Variable \[ $r ; Value: MBS ( "[GMImage.InvertChannel](GMImageInvertChannel.md)"; $image ; "rgb") \]   
Set Field \[ Invert::Output ; MBS ( "[GMImage.WriteToPNGContainer](GMImageWriteToPNGContainer.md)"; $image ; "output.png") \]   
Set Variable \[ $r ; Value: MBS ( "[GMImage.Release](GMImageRelease.md)"; $image ) \]  
### See also

- [GMImage.ReadContainer](GMImageReadContainer.md)
- [GMImage.WriteToContainer](GMImageWriteToContainer.md)
- [GMImage.WriteToTiffContainer](GMImageWriteToTiffContainer.md)
- [GMImage.WriteToWebPContainer](GMImageWriteToWebPContainer.md)
- [ImageView.CreateWithSize](ImageViewCreateWithSize.md)
- [OCR.GetText](OCRGetText.md)
- [OCR.GetTextWithCoordinates](OCRGetTextWithCoordinates.md)
- [Window.SetTitleIcon](WindowSetTitleIcon.md)
- [WinPDF.PageImage](WinPDFPageImage.md)
- [XL.Book.AddPictureContainer](XLBookAddPictureContainer.md)

### Release notes

- **Version 13.0**
    - Changed JPEG loader for [GMImage.NewFromContainer](https://www.mbsplugins.eu/GMImageNewFromContainer.shtml), [GMImage.NewFromFile](https://www.mbsplugins.eu/GMImageNewFromFile.shtml) and related to not stop loading of an image on a warning.
- **Version 9.5**
    - Improved JPEG detection for byte streams, so we can detect if a PNG is actually a JPEG. Now [GMImage.NewFromContainer](http://www.mbsplugins.eu/GMImageNewFromContainer.shtml) can read JPEG, GIF, PNG, TIFF and BMP even if they are passed in wrong container format.
- **Version 9.0**
    - Improved error handling for [GMImage.NewFromContainer](http://www.mbsplugins.eu/GMImageNewFromContainer.shtml), so we pass on error messages from GraphicsMagick.
- **Version 8.3**
    - Fixed [GMImage.NewFromContainer](http://www.mbsplugins.eu/GMImageNewFromContainer.shtml) to handle SVG files better.
- **Version 7.2**
    - Fixed a bug with [GMImage.NewFromContainer](http://www.mbsplugins.eu/GMImageNewFromContainer.shtml) where referenced image file would stay open.

### Example Databases

- [Containers/Create Container Preview](https://www.mbsplugins.eu/MBS-FileMaker-Plugin-Examples/Containers/Create%20Container%20Preview.shtml#1ScriptAnchor_)
- [DynaPDF/Click Points](https://www.mbsplugins.eu/MBS-FileMaker-Plugin-Examples/DynaPDF/Click%20Points.shtml#2ScriptAnchor_)
- [GraphicsMagick/Annotate Image](https://www.mbsplugins.eu/MBS-FileMaker-Plugin-Examples/GraphicsMagick/Annotate%20Image.shtml#2ScriptAnchor_)
- [GraphicsMagick/Clip Image](https://www.mbsplugins.eu/MBS-FileMaker-Plugin-Examples/GraphicsMagick/Clip%20Image.shtml#1ScriptAnchor_)
- [GraphicsMagick/Combine Pictures](https://www.mbsplugins.eu/MBS-FileMaker-Plugin-Examples/GraphicsMagick/Combine%20Pictures.shtml#1ScriptAnchor_)
- [GraphicsMagick/Correct Image Orientation](https://www.mbsplugins.eu/MBS-FileMaker-Plugin-Examples/GraphicsMagick/Correct%20Image%20Orientation.shtml#12910FieldAnchor_)
- [GraphicsMagick/GraphicsMagick IPTC](https://www.mbsplugins.eu/MBS-FileMaker-Plugin-Examples/GraphicsMagick/GraphicsMagick%20IPTC.shtml#1ScriptAnchor_)
- [GraphicsMagick/Image Scaling](https://www.mbsplugins.eu/MBS-FileMaker-Plugin-Examples/GraphicsMagick/Image%20Scaling.shtml#1ScriptAnchor_)
- [GraphicsMagick/Pick color from image via Screenshot](https://www.mbsplugins.eu/MBS-FileMaker-Plugin-Examples/GraphicsMagick/Pick%20color%20from%20image%20via%20Screenshot.shtml#1ScriptAnchor_)
- [GraphicsMagick/SVG to PNG](https://www.mbsplugins.eu/MBS-FileMaker-Plugin-Examples/GraphicsMagick/SVG%20to%20PNG.shtml#2ScriptAnchor_)

### Blog Entries

- [MBS Plugin Advent calendar: 16 - GraphicsMagick](https://www.mbsplugins.de/archive/2023-12-16/MBS_Plugin_Advent_calendar_16_/monkeybreadsoftware_blog_filemaker)
- [Tips and tricks with MBS](https://www.mbsplugins.de/archive/2023-08-10/Tips_and_tricks_with_MBS/monkeybreadsoftware_blog_filemaker)
- [Create thumbnail with GraphicsMagick](https://www.mbsplugins.de/archive/2023-04-15/Create_thumbnail_with_Graphics/monkeybreadsoftware_blog_filemaker)
- [GraphicsMagick in FileMaker, part 24](https://www.mbsplugins.de/archive/2022-12-24/GraphicsMagick_in_FileMaker_pa/monkeybreadsoftware_blog_filemaker)
- [GraphicsMagick in FileMaker, part 23](https://www.mbsplugins.de/archive/2022-12-23/GraphicsMagick_in_FileMaker_pa/monkeybreadsoftware_blog_filemaker)
- [GraphicsMagick in FileMaker, part 22](https://www.mbsplugins.de/archive/2022-12-22/GraphicsMagick_in_FileMaker_pa/monkeybreadsoftware_blog_filemaker)
- [GraphicsMagick in FileMaker, part 19](https://www.mbsplugins.de/archive/2022-12-19/GraphicsMagick_in_FileMaker_pa/monkeybreadsoftware_blog_filemaker)
- [GraphicsMagick in FileMaker, part 18](https://www.mbsplugins.de/archive/2022-12-18/GraphicsMagick_in_FileMaker_pa/monkeybreadsoftware_blog_filemaker)
- [GraphicsMagick in FileMaker, part 13](https://www.mbsplugins.de/archive/2022-12-13/GraphicsMagick_in_FileMaker_pa/monkeybreadsoftware_blog_filemaker)
- [GraphicsMagick in FileMaker, part 10](https://www.mbsplugins.de/archive/2022-12-10/GraphicsMagick_in_FileMaker_pa/monkeybreadsoftware_blog_filemaker)

### FileMaker Magazin

- [Ausgabe 2/2023, Seite 28](https://filemaker-magazin.de/neuigkeit/4223-Appetithappen-FMM_202302)
- [Ausgabe 6/2020, Seite 37](https://filemaker-magazin.de/neuigkeit/4118-Appetithappen-FMM_202006)
- [Ausgabe 5/2018, Seite 29](https://filemaker-magazin.de/neuigkeit/4011-Appetithappen-FMM_201805)
- [Ausgabe 5/2011, Seite 32](https://filemaker-magazin.de/neuigkeit/3506-Appetithappen-FMM_201105-06)

This function checks for a license.

Created 18th August 2014 , last changed 22nd November 2023

  
[GMImage.NewFromBase64](GMImageNewFromBase64.md) - [GMImage.NewFromFile](GMImageNewFromFile.md)

[HTML Version](GMImageNewFromContainer.shtml)