GMImage.WriteToJPEGContainer
----------------------------

Writes the picture in JPEG format to a container value which you can store in a container field.

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

MBS( "GMImage.WriteToJPEGContainer"; ImageRef { ; FileName } ) 

**MBS**( **"GMImage.WriteToJPEGContainer";** /\* Writes the picture in JPEG format to a container value which you can store in a container field. \*/  
**$ImageRef**; /\* The image reference number.e.g. 1 \*/   
**$FileName**) /\* Optional; The file name to use for the container. Default is "image.jpg"e.g. "ball.jpg" \*/ 

### Parameters

| Parameter | Description | Example | Flags |
|---|---|---|---|
| ImageRef | The image reference number. | 1 |  |
| FileName | The file name to use for the container. Default is "image.jpg" | "ball.jpg" | Optional |

### Result

Returns a container value.

### Description

Writes the picture in JPEG format to a container value which you can store in a container field.  
Includes a file name "image.jpg" and the image size.  
For the quality setting use the [GMImage.SetQuality](GMImageSetQuality.md) function.   
For most cases the PNG file format is the better choice as it supports transparency and lossless compression.  
See also [GMImage.WriteToFile](GMImageWriteToFile.md), [GMImage.WriteToPNGContainer](GMImageWriteToPNGContainer.md), [GMImage.WriteToTiffContainer](GMImageWriteToTiffContainer.md), [GMImage.WriteToBMPContainer](GMImageWriteToBMPContainer.md) and [GMImage.WriteToGIFContainer](GMImageWriteToGIFContainer.md).  
### Examples

Recompresses the image with JPEG compressor and a really bad quality:

 Let ( \[   
$Image = MBS ("[GMImage.NewFromContainer](GMImageNewFromContainer.md)"; GraphicsMagick::image );   
$Result = MBS ("[GMImage.SetQuality](GMImageSetQuality.md)";$Image ; 5);   
$Result = MBS ("GMImage.WriteToJPEGContainer"; $Image );   
$Error = MBS ("[GMImage.Release](GMImageRelease.md)";$Image )  
\];   
$Result )  
Save JPEG image to container as script:

 Set Variable \[ $Image ; Value: MBS ("[GMImage.NewFromContainer](GMImageNewFromContainer.md)"; MyTable::BMPContainer ) \]   
Set Variable \[ $r ; Value: MBS ("[GMImage.SetQuality](GMImageSetQuality.md)";$Image ; 90) \]   
Set Field \[ MyTable::JPEGContainer ; MBS ("GMImage.WriteToJPEGContainer"; $Image ) \]   
Set Variable \[ $r ; Value: MBS ("[GMImage.Release](GMImageRelease.md)";$Image ) \]  
Read image and scale down for preview:

 Set Variable \[ $image ; Value: MBS ( "[GMImage.NewFromContainer](GMImageNewFromContainer.md)"; $input ) \]   
If \[ MBS ("IsError") = 0 \]   
 # limit size  
 Set Variable \[ $scale ; Value: MBS ("[GMImage.Scale](GMImageScale.md)";$Image ; "1000&gt;") \]   
 # remove metadata  
 Set Variable \[ $r ; Value: MBS ( "[GMImage.SetProfile](GMImageSetProfile.md)"; $image ; "IPTC"; "" ) \]   
 Set Variable \[ $r ; Value: MBS ( "[GMImage.SetProfile](GMImageSetProfile.md)"; $image ; "EXIF"; "" ) \]   
 Set Variable \[ $r ; Value: MBS ( "[GMImage.SetProfile](GMImageSetProfile.md)"; $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 ; "GraphicsMagick" \]   
 Set Variable \[ $r ; Value: MBS ("[GMImage.Release](GMImageRelease.md)";$Image ) \]   
 Exit Script \[ Text Result: \]   
 End If  
 Set Variable \[ $r ; Value: MBS ("[GMImage.Release](GMImageRelease.md)";$Image ) \]   
End If  
### See also

- [GMImage.SetQuality](GMImageSetQuality.md)
- [GMImage.SetResolutionUnits](GMImageSetResolutionUnits.md)
- [GMImage.Solarize](GMImageSolarize.md)
- [GMImage.Threshold](GMImageThreshold.md)
- [GMImage.Trim](GMImageTrim.md)
- [GMImage.WriteToBMPContainer](GMImageWriteToBMPContainer.md)
- [GMImage.WriteToContainer](GMImageWriteToContainer.md)
- [GMImage.WriteToFile](GMImageWriteToFile.md)
- [GMImage.WriteToGIFContainer](GMImageWriteToGIFContainer.md)
- [GMImage.WriteToPNGContainer](GMImageWriteToPNGContainer.md)

### Example Databases

- [Containers/Create Container Preview](https://www.mbsplugins.eu/MBS-FileMaker-Plugin-Examples/Containers/Create%20Container%20Preview.shtml#1ScriptAnchor_)
- [GraphicsMagick/Correct Image Orientation](https://www.mbsplugins.eu/MBS-FileMaker-Plugin-Examples/GraphicsMagick/Correct%20Image%20Orientation.shtml#1ScriptAnchor_)
- [GraphicsMagick/Crop with Clicks](https://www.mbsplugins.eu/MBS-FileMaker-Plugin-Examples/GraphicsMagick/Crop%20with%20Clicks.shtml#3ScriptAnchor_)
- [GraphicsMagick/Image Scaling](https://www.mbsplugins.eu/MBS-FileMaker-Plugin-Examples/GraphicsMagick/Image%20Scaling.shtml#3ScriptAnchor_)
- [GraphicsMagick/Reduce Image](https://www.mbsplugins.eu/MBS-FileMaker-Plugin-Examples/GraphicsMagick/Reduce%20Image.shtml#1ScriptAnchor_)
- [GraphicsMagick/Rotate Orientation](https://www.mbsplugins.eu/MBS-FileMaker-Plugin-Examples/GraphicsMagick/Rotate%20Orientation.shtml#1ScriptAnchor_)
- [GraphicsMagick/Trim Picture](https://www.mbsplugins.eu/MBS-FileMaker-Plugin-Examples/GraphicsMagick/Trim%20Picture.shtml#1ScriptAnchor_)

### Blog Entries

- [New in MBS FileMaker Plugin 13.2](https://www.mbsplugins.de/archive/2023-05-17/New_in_MBS_FileMaker_Plugin_13/monkeybreadsoftware_blog_filemaker)
- [Create thumbnail with GraphicsMagick](https://www.mbsplugins.de/archive/2023-04-15/Create_thumbnail_with_Graphics/monkeybreadsoftware_blog_filemaker)
- [GraphicsMagick in FileMaker, part 23](https://www.mbsplugins.de/archive/2022-12-23/GraphicsMagick_in_FileMaker_pa/monkeybreadsoftware_blog_filemaker)
- [GraphicsMagick in FileMaker, part 3](https://www.mbsplugins.de/archive/2022-12-03/GraphicsMagick_in_FileMaker_pa/monkeybreadsoftware_blog_filemaker)
- [Correct Image Orientation in FileMaker](https://www.mbsplugins.de/archive/2018-11-09/Correct_Image_Orientation_in_F/monkeybreadsoftware_blog_filemaker)
- [Comparing Base Elements Plugin to MBS FileMaker Plugin](https://www.mbsplugins.de/archive/2017-10-24/Comparing_Base_Elements_Plugin/monkeybreadsoftware_blog_filemaker)
- [MBS Filemaker Plugin 2.4 release notes](https://www.mbsplugins.de/archive/2011-10-11/MBS_Filemaker_Plugin_24_releas/monkeybreadsoftware_blog_filemaker)
- [MBS Filemaker Plugin, version 2.4pr3](https://www.mbsplugins.de/archive/2011-05-14/MBS_Filemaker_Plugin_version_2/monkeybreadsoftware_blog_filemaker)

### FileMaker Magazin

- [Ausgabe 5/2018, Seite 26](https://filemaker-magazin.de/neuigkeit/4011-Appetithappen-FMM_201805)
- [Ausgabe 5/2011, Seite 33](https://filemaker-magazin.de/neuigkeit/3506-Appetithappen-FMM_201105-06)

This function checks for a license.

Created 18th August 2014 , last changed 15th April 2023

  
[GMImage.WriteToGIFContainer](GMImageWriteToGIFContainer.md) - [GMImage.WriteToPDFContainer](GMImageWriteToPDFContainer.md)

[HTML Version](GMImageWriteToJPEGContainer.shtml)