Jump to content
Salesforce and other SMB Solutions are coming soon. ×

Convert HEIF images if needed


Recommended Posts

  • Advertiser

Recently a client contacted us for a problem they have. A solution hosted via FileMaker Server with Web Direct shows a layout with a container. Users can click on a button to upload an image, which uses Insert from Device script step. But if the user has an iPhone, the uploaded image may be an HEIF one. The High Efficiency Image File Format is great to preserve images in high quality, but other tools may not be able to read it. And we run into the problem, that the container is marked to be of type JPEG, which confuses other scripts (see Container.GetTypes function).


Here is a script to look on the inserted image and convert it to PNG with our Container.ReadImage function:  


# 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 ; $name ] 


Show Custom Dialog [ "Read Image Failed?" ; $image ] 

End If

End If 


As you see we also rename the name for the container, so it matches the content. You can decide if you prefer JPEG (smaller, no alpha channel), PNG (higher quality and alpha channel possible) or another type.


This script can be used on FileMaker Server on macOS where our plugin can use the built-in system functions. Otherwise you can run it in FileMaker Pro or in your iOS app based on the FileMaker iOS SDK.

Link to comment
Share on other sites

This thread is quite old. Please start a new thread rather than reviving this one.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • Create New...

Important Information

Terms of Use