GMImage.NewFromFile
-------------------

Loads a picture file.

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

MBS( "GMImage.NewFromFile"; Path { ; Magick } ) 

**MBS**( **"GMImage.NewFromFile";** /\* Loads a picture file. \*/  
**$Path**; /\* The platform specific file path.e.g. "/test.jpg" \*/   
**$Magick**) /\* Optional; The magick setting to define which codec to use.e.g. "JPG" \*/ 

### Parameters

| Parameter | Description | Example | Flags |
|---|---|---|---|
| Path | The platform specific file path. | "/test.jpg" |  |
| Magick | The magick setting to define which codec to use. | "JPG" | Optional      Added in version **8.4**. |

### Result

Returns the ImageRef number on success.

### Description

Loads a picture file.  
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 to PNG and then use [GMImage.NewFromContainer](GMImageNewFromContainer.md) function.  
  
When the file is a PDF, 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.  
  
On Windows the file APIs in GraphicsMagick only do ANSI file paths. MacOS and Linux can do full Unicode.  
  
This function requires a native path. Use [Path.FileMakerPathToNativePath](PathFileMakerPathToNativePath.md) to convert a FileMaker path to a native path if required. If you like to have the user choose the path, you can use [FileDialog](component_FileDialog.md) functions.  
For Server be aware that server has limited permissions and may not be able to access all files on a computer.  
### Examples

Load an image from file path:

 # Loads a picture file and returns the ImageRef number on success   
Set Variable \[ $RefNum ; Value:MBS ( "GMImage.NewFromFile"; $currentPicturePath ) \]  
### See also

- [GMImage.GetProfile](GMImageGetProfile.md)
- [GMImage.GetType](GMImageGetType.md)
- [GMImage.Minify](GMImageMinify.md)
- [GMImage.New](GMImageNew.md)
- [GMImage.NewFromBase64](GMImageNewFromBase64.md)
- [GMImage.Profiles](GMImageProfiles.md)
- [GMImage.Release](GMImageRelease.md)
- [Path.FileMakerPathToNativePath](PathFileMakerPathToNativePath.md)
- [PDFKit.GetPDFPageImage](PDFKitGetPDFPageImage.md)
- [WinPDF.PageImage](WinPDFPageImage.md)

### Release notes

- **Version 14.4**
    - Fixed a problem with [GMImage.NewFromFile](https://www.mbsplugins.eu/GMImageNewFromFile.shtml) and Japanese characters on Windows.
- **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 8.4**
    - Added Magick parameter for [GMImage.NewFromFile](http://www.mbsplugins.eu/GMImageNewFromFile.shtml) function.
    - Fixed problem with [GMImage.NewFromFile](http://www.mbsplugins.eu/GMImageNewFromFile.shtml) function.

### Example Databases

- [DynaPDF/Scan with WIA to PDF](https://www.mbsplugins.eu/MBS-FileMaker-Plugin-Examples/DynaPDF/Scan%20with%20WIA%20to%20PDF.shtml#24ScriptAnchor_)

### Blog Entries

- [MBS FileMaker Plugin, version 14.4pr3](https://www.mbsplugins.de/archive/2024-08-21/MBS_FileMaker_Plugin_version_1/monkeybreadsoftware_blog_filemaker)
- [Tips and tricks with MBS](https://www.mbsplugins.de/archive/2023-08-10/Tips_and_tricks_with_MBS/monkeybreadsoftware_blog_filemaker)
- [GraphicsMagick in FileMaker, part 7](https://www.mbsplugins.de/archive/2022-12-07/GraphicsMagick_in_FileMaker_pa/monkeybreadsoftware_blog_filemaker)
- [GraphicsMagick in FileMaker, part 5](https://www.mbsplugins.de/archive/2022-12-05/GraphicsMagick_in_FileMaker_pa/monkeybreadsoftware_blog_filemaker)
- [GraphicsMagick in FileMaker, part 4](https://www.mbsplugins.de/archive/2022-12-04/GraphicsMagick_in_FileMaker_pa/monkeybreadsoftware_blog_filemaker)
- [MBS FileMaker Plugin, version 12.6pr1](https://www.mbsplugins.de/archive/2022-12-01/MBS_FileMaker_Plugin_version_1/monkeybreadsoftware_blog_filemaker)
- [GraphicsMagick in FileMaker, part 1](https://www.mbsplugins.de/archive/2022-12-01/GraphicsMagick_in_FileMaker_pa/monkeybreadsoftware_blog_filemaker)
- [Create PDF from scanned images and skip blank pages](https://www.mbsplugins.de/archive/2019-03-13/Create_PDF_from_scanned_images/monkeybreadsoftware_blog_filemaker)
- [MBS FileMaker Plugin, version 8.4pr4](https://www.mbsplugins.de/archive/2018-08-21/MBS_FileMaker_Plugin_version_8/monkeybreadsoftware_blog_filemaker)
- [MBS FileMaker Plugin, version 8.4pr1](https://www.mbsplugins.de/archive/2018-08-01/MBS_FileMaker_Plugin_version_8/monkeybreadsoftware_blog_filemaker)

This function checks for a license.

Created 18th August 2014 , last changed 19th August 2024

  
[GMImage.NewFromContainer](GMImageNewFromContainer.md) - [GMImage.NewFromHex](GMImageNewFromHex.md)

[HTML Version](GMImageNewFromFile.shtml)