Container.ReadImage
-------------------

Reads and convert image.

| Component | Version | macOS | Windows | Linux | Server | iOS SDK |
|---|---|---|---|---|---|---|
| [Container](component_Container.md) | [8.4](newinversion84.md) | ✅ Yes | ✅ Yes | ❌ No | ✅ Yes, on macOS and Windows | ✅ Yes |

MBS( "Container.ReadImage"; Container { ; ImageType; FileName } ) 

**MBS**( **"Container.ReadImage";** /\* Reads and convert image. \*/  
**$Container**; /\* The container field or value to inspect.e.g. MyTable::MyContainerField \*/   
**$ImageType**; /\* Optional; The type of image to return.   
Either JPEG, PNG, GIF or BMP. Default is JPEG.e.g. "JPEG" \*/   
**$FileName**) /\* Optional; The filename to use for the picture.   
Default is "image" with the extension matching the image type.e.g. "test.jpg" \*/ 

### Parameters

| Parameter | Description | Example | Flags |
|---|---|---|---|
| Container | The container field or value to inspect. | MyTable::MyContainerField |  |
| ImageType | The type of image to return.    Either JPEG, PNG, GIF or BMP. Default is JPEG. | "JPEG" | Optional |
| FileName | The filename to use for the picture.    Default is "image" with the extension matching the image type. | "test.jpg" | Optional |

### Result

Returns image container or error.

### Description

Reads and convert image.  
This function is useful to read all the image formats supported by Apple's frameworks and convert them to a common format like JPEG or PNG.  
Use this function to convert old PICT images in containers.  
Works as well for HEIC and HEIF images.  
  
Added Windows support in v13.0. You need to install HEIF Image Extensions from the Windows App Store.  
  
Reads webp files on macOS.  
Supports JPEG-XL files for macOS 15.2 and iOS 18.2 or newer.  
  
Please use [Container.ReadFile](ContainerReadFile.md) on Linux instead.  
### Examples

Convert PICT to PNG:

 Set Field \[ Test::output ; MBS ("Container.ReadImage"; Test::OldImage ; "PNG"; "image.png") \]  
Read file from disk and read as image:

 Set Field \[ Batch Emailer::Inline Graphics ; MBS ("Container.ReadImage"; MBS ("[Container.ReadFile](ContainerReadFile.md)"; "/Users/cs/Desktop/test.heic")) \]  
Read HEIC file:

 Set Variable \[ $path ; Value: "/Users/cs/Desktop/IMG\_3552.HEIC" \]   
Set Variable \[ $container ; Value: MBS ( "[Container.ReadFile](ContainerReadFile.md)"; $path ) \]   
If \[ MBS ("IsError") = 0 \]   
 Set Variable \[ $image ; Value: MBS ( "Container.ReadImage"; $container ; "PNG"; "image.png") \]   
 If \[ MBS ("IsError") = 0 \]   
 Set Field \[ Untitled::image ; $image \]   
 End If  
End If  
Convert a PSD or HEIF image to PNG:

 Set Field \[ Contacts::Output ; MBS ( "Container.ReadImage"; Contacts::Input ; "PNG"; "test.png" ) \]  
Insert picture from device and then convert HEIF

 # let user take a picture   
Insert from Device \[ Contacts::Photo Container ; Type: Camera ; Camera: Back; Resolution: Full \]   
\#   
\# check filename   
Set Variable \[ $name ; Value: GetAsText(Contacts::Photo Container) \]   
Set Variable \[ $extension ; Value: Right ( $name ; 5 ) \]   
If \[ $extension = ".heif" or $extension = ".heic" \]   
 # we got a HEIF image  
 #   
 # get new file name  
 Set Variable \[ $name ; Value: Substitute($name ; ".heif"; ".png") \]   
 Set Variable \[ $name ; Value: Substitute($name ; ".heic"; ".png") \]   
 #   
 # now convert to PNG  
 Set Variable \[ $image ; Value: MBS ( "Container.ReadImage"; Contacts::Photo Container; "PNG"; $name ) \]   
 If \[ MBS ("IsError") = 0 \]   
 # save on success to container  
 Set Field \[ Contacts::Photo Container ; $image \]   
 Else  
 Show Custom Dialog \[ "Read Image Failed?" ; $image \]   
 End If  
End If  
Read image and scale down as thumbnail:

 # Try plugin to read more formats known by OS   
Set Variable \[ $imageData ; Value: MBS ( "Container.ReadImage"; $input ; "PNG"; "image.png") \]   
If \[ MBS ("IsError") = 0 and not IsEmpty ( $imageData ) \]   
 # scale down?  
 Set Variable \[ $image ; Value: MBS ( "[GMImage.NewFromContainer](GMImageNewFromContainer.md)"; $imageData ) \]   
 If \[ MBS ("IsError") = 0 \]   
 # limit size to 1000 pixel maximum  
 Set Variable \[ $scale ; Value: MBS ("[GMImage.Scale](GMImageScale.md)";$Image ; "1000&gt;") \]   
 # remove metadata  
 Set Variable \[ $r ; Value: MBS ( "[GMImage.SetProfile](GMImageSetProfile.md)"; $image ; "IPTC"; "" ) \]   
 Set Variable \[ $r ; Value: MBS ( "[GMImage.SetProfile](GMImageSetProfile.md)"; $image ; "EXIF"; "" ) \]   
 Set Variable \[ $r ; Value: MBS ( "[GMImage.SetProfile](GMImageSetProfile.md)"; $image ; "XMP"; "" ) \]   
 # save  
 Set Variable \[ $NewImage ; Value: MBS ("[GMImage.WriteToJPEGContainer](GMImageWriteToJPEGContainer.md)"; $Image ) \]   
 If \[ MBS ("IsError") = 0 \]   
 Set Field \[ Get Preview::Preview ; $NewImage \]   
 Set Field \[ Get Preview::Made using ; "ReadImage" \]   
 Exit Script \[ Text Result: \]   
 End If  
 Set Variable \[ $r ; Value: MBS ("[GMImage.Release](GMImageRelease.md)";$Image ) \]   
 End If  
 #   
 Set Field \[ Get Preview::Preview ; $imageData \]   
 Exit Script \[ Text Result: \]   
End If  
### See also

- [Container.ReadFile](ContainerReadFile.md)
- [Container.ReadImageFile](ContainerReadImageFile.md)
- [CURL.GetResultAsContainer](CURLGetResultAsContainer.md)
- [GMImage.New](GMImageNew.md)
- [GMImage.NewFromFile](GMImageNewFromFile.md)
- [GMImage.Release](GMImageRelease.md)
- [GMImage.Scale](GMImageScale.md)
- [GMImage.WriteToJPEGContainer](GMImageWriteToJPEGContainer.md)
- [IsError](IsError.md)
- [PhotoPicker.File](PhotoPickerFile.md)

### Release notes

- **Version 14.5**
    - Improved [Container.ReadImage](https://www.mbsplugins.eu/ContainerReadImage.shtml) to read HEIC images on iOS.
- **Version 13.1**
    - Added Windows support for [Container.ReadImage](https://www.mbsplugins.eu/ContainerReadImage.shtml) and [Container.ReadImageFile](https://www.mbsplugins.eu/ContainerReadImageFile.shtml) functions to e.g. load HEIF/HEIC files on Windows.
    - Fixed a problem with [Container.ReadImage](https://www.mbsplugins.eu/ContainerReadImage.shtml) function returning error about NSRange being wrong.
- **Version 11.2**
    - Added [Container.ReadImageFile](https://www.mbsplugins.eu/ContainerReadImageFile.shtml) function.
    - Improved memory usage of [Container.ReadImage](https://www.mbsplugins.eu/ContainerReadImage.shtml), [PDFKit.GeneratePreview](https://www.mbsplugins.eu/PDFKitGeneratePreview.shtml) and [PDFKit.GetPDFPageImage](https://www.mbsplugins.eu/PDFKitGetPDFPageImage.shtml) functions, especially for server.
- **Version 10.5**
    - Fixed memory leaks in [BinaryFile.WriteContainer](https://www.mbsplugins.eu/BinaryFileWriteContainer.shtml), [Container.ReadImage](https://www.mbsplugins.eu/ContainerReadImage.shtml), [Vision.ClassifyImage](https://www.mbsplugins.eu/VisionClassifyImage.shtml), [Vision.DetectBarcode](https://www.mbsplugins.eu/VisionDetectBarcode.shtml) and [Vision.RecognizeText](https://www.mbsplugins.eu/VisionRecognizeText.shtml) functions.
- **Version 8.4**
    - Added [Container.ReadImage](http://www.mbsplugins.eu/ContainerReadImage.shtml) function.

### Example Databases

- [Containers/Create Container Preview](https://www.mbsplugins.eu/MBS-FileMaker-Plugin-Examples/Containers/Create%20Container%20Preview.shtml#1ScriptAnchor_)
- [DynaPDF/Merge PDFs](https://www.mbsplugins.eu/MBS-FileMaker-Plugin-Examples/DynaPDF/Merge%20PDFs.shtml#11ScriptAnchor_)

### Blog Entries

- [MBS FileMaker Plugin, version 14.5pr5](https://www.mbsplugins.de/archive/2024-10-28/MBS_FileMaker_Plugin_version_1/monkeybreadsoftware_blog_filemaker)
- [Page Layouting in DynaPDF](https://www.mbsplugins.de/archive/2024-04-05/Page_Layouting_in_DynaPDF/monkeybreadsoftware_blog_filemaker)
- [Identify data content](https://www.mbsplugins.de/archive/2024-01-15/Identify_data_content/monkeybreadsoftware_blog_filemaker)
- [MBS @ FMTraining.TV - Changing Image Formats in Containers with the MBS FileMaker Plug-in](https://www.mbsplugins.de/archive/2024-01-12/MBS_@_FMTrainingTV_-_Changing_/monkeybreadsoftware_blog_filemaker)
- [Merge documents with DynaPDF](https://www.mbsplugins.de/archive/2023-07-06/Merge_documents_with_DynaPDF/monkeybreadsoftware_blog_filemaker)
- [MBS Plugin 13.1 for Claris FileMaker](https://www.mbsplugins.de/archive/2023-03-07/MBS_Plugin_131_for_Claris_File/monkeybreadsoftware_blog_filemaker)
- [MBS FileMaker Plugin, version 13.1pr4](https://www.mbsplugins.de/archive/2023-02-24/MBS_FileMaker_Plugin_version_1/monkeybreadsoftware_blog_filemaker)
- [OCR on Windows in FileMaker](https://www.mbsplugins.de/archive/2023-02-07/OCR_on_Windows_in_FileMaker/monkeybreadsoftware_blog_filemaker)
- [Convert HEIF images if needed](https://www.mbsplugins.de/archive/2021-06-17/Convert_HEIF_images_if_needed/monkeybreadsoftware_blog_filemaker)
- [Read HEIC or HEIF image files in FileMaker](https://www.mbsplugins.de/archive/2019-08-20/Read_HEIC_or_HEIF_image_files_/monkeybreadsoftware_blog_filemaker)

This function is free to use.

Created 29th July 2018 , last changed 25th February 2026

  
[Container.ReadFile](ContainerReadFile.md) - [Container.ReadImageFile](ContainerReadImageFile.md)

[HTML Version](ContainerReadImage.shtml)