CGImageSource.Export
--------------------

Exports the image as container value.

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

MBS( "CGImageSource.Export"; Ref; FileName ) 

**MBS**( **"CGImageSource.Export";** /\* Exports the image as container value. \*/  
**$Ref**; /\* The image source reference number returned by [CGImageSource.CreateWithData](CGImageSourceCreateWithData.md), [CGImageSource.CreateWithPath](CGImageSourceCreateWithPath.md) or [CGImageSource.CreateWithURL](CGImageSourceCreateWithURL.md) \*/   
**$FileName**) /\* The file name to use.  
If empty, we use the name of the loaded image.  
Falls back to export.jpg if no name is provided.  
Image destination is defined by file type from file name.e.g. "test.jpg" \*/ 

### Parameters

| Parameter | Description | Example |
|---|---|---|
| Ref | The image source reference number returned by [CGImageSource.CreateWithData](CGImageSourceCreateWithData.md), [CGImageSource.CreateWithPath](CGImageSourceCreateWithPath.md) or [CGImageSource.CreateWithURL](CGImageSourceCreateWithURL.md) | $ref |
| FileName | The file name to use.   If empty, we use the name of the loaded image.   Falls back to export.jpg if no name is provided.   Image destination is defined by file type from file name. | "test.jpg" |

### Result

Returns container value or error.

### Description

Exports the image as container value.  
Uses the image compression based on the file name used.  
If possible, we move through data without recompressing image.  
  
Use [Container.WriteFile](ContainerWriteFile.md) to write the image to a disk file.  
### Examples

Changes some metadata and exports image:

 Set Variable \[ $ref ; Value: MBS ("[CGImageSource.CreateWithData](CGImageSourceCreateWithData.md)"; CGImageSource::ImageFile ) \]   
Set Variable \[ $keys ; Value: MBS ( "[CGImageSource.SetProperty](CGImageSourceSetProperty.md)"; $ref ; 0; "{IPTC}.Keywords"; "House,Garden" ) \]   
Set Variable \[ $keys ; Value: MBS ( "[CGImageSource.SetProperty](CGImageSourceSetProperty.md)"; $ref ; 0; "{IPTC}.Caption/Abstract"; "House with garden" ) \]   
Set Variable \[ $keys ; Value: MBS ( "[CGImageSource.SetProperty](CGImageSourceSetProperty.md)"; $ref ; 0; "{TIFF}.ImageDescription"; "House with garden" ) \]   
Set Variable \[ $Image ; Value: MBS ("CGImageSource.Export"; $ref ) \]   
Set Field \[ CGImageSource::output ; $image \]   
Set Variable \[ $r ; Value: MBS ("[CGImageSource.Release](CGImageSourceRelease.md)"; $ref ) \]  
### See also

- [CGImageSource.Count](CGImageSourceCount.md)
- [CGImageSource.CreateWithData](CGImageSourceCreateWithData.md)
- [CGImageSource.CreateWithPath](CGImageSourceCreateWithPath.md)
- [CGImageSource.CreateWithURL](CGImageSourceCreateWithURL.md)
- [CGImageSource.List](CGImageSourceList.md)
- [CGImageSource.Property](CGImageSourceProperty.md)
- [CGImageSource.Release](CGImageSourceRelease.md)
- [CGImageSource.SetProperty](CGImageSourceSetProperty.md)
- [CGImageSource.Type](CGImageSourceType.md)
- [Container.WriteFile](ContainerWriteFile.md)

### Release notes

- **Version 9.4**
    - Added [CGImageSource.Export](http://www.mbsplugins.eu/CGImageSourceExport.shtml) and [CGImageSource.SupportedExportTypes](http://www.mbsplugins.eu/CGImageSourceSupportedExportTypes.shtml) functions to export image.

### Example Databases

- [Mac and iOS/CGImageSource](https://www.mbsplugins.eu/MBS-FileMaker-Plugin-Examples/Mac%20and%20iOS/CGImageSource.shtml#2ScriptAnchor_)

### Blog Entries

- [Neue Funktionen des MBS FileMaker Plugin 9.4](https://www.mbsplugins.de/archive/2019-10-05/Neue_Funktionen_des_MBS_FileMa/monkeybreadsoftware_blog_filemaker)
- [MBS FileMaker Plugin, version 9.4pr5](https://www.mbsplugins.de/archive/2019-09-05/MBS_FileMaker_Plugin_version_9/monkeybreadsoftware_blog_filemaker)

This function checks for a license.

Created 30th August 2019 , last changed 12nd September 2019

  
[CGImageSource.CreateWithURL](CGImageSourceCreateWithURL.md) - [CGImageSource.FileName](CGImageSourceFileName.md)

[HTML Version](CGImageSourceExport.shtml)