CGImageSource.CreateWithPath
----------------------------

Creates an image source that reads from a location specified by a Path.

| Component | Version | macOS | Windows | Linux | Server | iOS SDK |
|---|---|---|---|---|---|---|
| [CGImageSource](component_CGImageSource.md) | [3.4](newinversion34.md) | ✅ Yes | ❌ No | ❌ No | ✅ Yes, on macOS | ✅ Yes |

MBS( "CGImageSource.CreateWithPath"; Path ) 

**MBS**( **"CGImageSource.CreateWithPath";** /\* Creates an image source that reads from a location specified by a Path. \*/  
**$Path**) /\* The platform specific native file path.e.g. "/test.jpg" \*/ 

### Parameters

| Parameter | Description | Example |
|---|---|---|
| Path | The platform specific native file path. | "/test.jpg" |

### Result

Returns the reference number for this image source or error message.

### Description

Creates an image source that reads from a location specified by a Path.  
Don't forget to call [CGImageSource.Release](CGImageSourceRelease.md) later to release the reference number.  
  
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 image and show it:

 Set Variable \[ $path ; Value: "/Users/cs/Pictures/IMG\_3625.jpg" \]   
Set Variable \[ $img ; Value: MBS ( "CGImageSource.CreateWithPath"; $path ) \]   
Set Field \[ test::output ; MBS ( "[CGImageSource.ImageAtIndex](CGImageSourceImageAtIndex.md)"; $img ; 0) \]   
Set Variable \[ $r ; Value: MBS ( "[CGImageSource.Release](CGImageSourceRelease.md)"; $img ) \]  
Read HEIC image:

 Set Variable \[ $path ; Value: "/Users/cs/Desktop/IMG\_3552.HEIC" \]   
Set Variable \[ $ImageSource ; Value: MBS ( "CGImageSource.CreateWithPath"; $path ) \]   
If \[ MBS ("IsError") = 0 \]   
 # you can get metadata as JSON to check later...  
 Set Variable \[ $$MetaData ; Value: MBS ( "[CGImageSource.Properties](CGImageSourceProperties.md)"; $ImageSource ) \]   
 Set Variable \[ $$ImageMetaData ; Value: MBS ( "[CGImageSource.Properties](CGImageSourceProperties.md)"; $ImageSource ; 0 ) \]   
 # get image to show  
 Set Variable \[ $image ; Value: MBS ( "[CGImageSource.ImageAtIndex](CGImageSourceImageAtIndex.md)"; $ImageSource ; 0; "PNG"; "image.png") \]   
 If \[ MBS ("IsError") = 0 \]   
 Set Field \[ Untitled::image ; $image \]   
 End If  
 Set Variable \[ $r ; Value: MBS ( "[CGImageSource.Release](CGImageSourceRelease.md)"; $ImageSource ) \]   
End If  
### See also

- [CGImageSource.CreateWithURL](CGImageSourceCreateWithURL.md)
- [CGImageSource.FileName](CGImageSourceFileName.md)
- [CGImageSource.Keys](CGImageSourceKeys.md)
- [CGImageSource.Properties](CGImageSourceProperties.md)
- [CGImageSource.Release](CGImageSourceRelease.md)
- [CGImageSource.SetProperty](CGImageSourceSetProperty.md)
- [CGImageSource.ThumbnailAtIndex](CGImageSourceThumbnailAtIndex.md)
- [CGImageSource.Type](CGImageSourceType.md)
- [IsError](IsError.md)
- [Path.FileMakerPathToNativePath](PathFileMakerPathToNativePath.md)

### Blog Entries

- [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 checks for a license.

Created 18th August 2014 , last changed 27th January 2020

  
[CGImageSource.CreateWithData](CGImageSourceCreateWithData.md) - [CGImageSource.CreateWithURL](CGImageSourceCreateWithURL.md)

[HTML Version](CGImageSourceCreateWithPath.shtml)