Components | All | New | MacOS | Windows | Linux | iOS | ||||
Examples | Mac & Win | Server | Client | Guides | Statistic | FMM | Blog | Deprecated | Old |
Container.ReadImage
Reads and convert image.
Component | Version | macOS | Windows | Linux | Server | iOS SDK |
Container | 8.4 | ✅ Yes | ✅ Yes | ❌ No | ✅ Yes, on macOS and Windows | ✅ Yes |
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.
Reads webp files on macOS.
Please use Container.ReadFile 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"; "/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"; $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"; $imageData) ]
If [ MBS("IsError") = 0 ]
# limit size to 1000 pixel maximum
Set Variable [ $scale ; Value: MBS("GMImage.Scale";$Image; "1000>") ]
# remove metadata
Set Variable [ $r ; Value: MBS( "GMImage.SetProfile"; $image; "IPTC"; "" ) ]
Set Variable [ $r ; Value: MBS( "GMImage.SetProfile"; $image; "EXIF"; "" ) ]
Set Variable [ $r ; Value: MBS( "GMImage.SetProfile"; $image; "XMP"; "" ) ]
# save
Set Variable [ $NewImage ; Value: MBS("GMImage.WriteToJPEGContainer"; $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";$Image) ]
End If
#
Set Field [ Get Preview::Preview ; $imageData ]
Exit Script [ Text Result: ]
End If
See also
- Container.ReadFile
- Container.ReadImageFile
- CURL.GetResultAsContainer
- GMImage.New
- GMImage.NewFromFile
- GMImage.Release
- GMImage.Scale
- GMImage.WriteToJPEGContainer
- IsError
- PhotoPicker.File
Release notes
- Version 14.5
- Improved Container.ReadImage to read HEIC images on iOS.
- Version 13.1
- Added Windows support for Container.ReadImage and Container.ReadImageFile functions to e.g. load HEIF/HEIC files on Windows.
- Fixed a problem with Container.ReadImage function returning error about NSRange being wrong.
- Version 11.2
- Added Container.ReadImageFile function.
- Improved memory usage of Container.ReadImage, PDFKit.GeneratePreview and PDFKit.GetPDFPageImage functions, especially for server.
- Version 10.5
- Fixed memory leaks in BinaryFile.WriteContainer, Container.ReadImage, Vision.ClassifyImage, Vision.DetectBarcode and Vision.RecognizeText functions.
- Version 8.4
- Added Container.ReadImage function.
Example Databases
Blog Entries
- MBS FileMaker Plugin, version 14.5pr5
- Page Layouting in DynaPDF
- Identify data content
- MBS @ FMTraining.TV - Changing Image Formats in Containers with the MBS FileMaker Plug-in
- Merge documents with DynaPDF
- MBS Plugin 13.1 for Claris FileMaker
- MBS FileMaker Plugin, version 13.1pr4
- OCR on Windows in FileMaker
- Convert HEIF images if needed
- Read HEIC or HEIF image files in FileMaker
This function is free to use.
Created 29th July 2018, last changed 23th August 2024