AVRecorder.CaptureStillPhoto
----------------------------

Captures a still image.

| Component | Version | macOS | Windows | Linux | Server | iOS SDK |
|---|---|---|---|---|---|---|
| [AVRecorder](component_AVRecorder.md) | [6.2](newinversion62.md) | ✅ Yes | ✅ Yes | ❌ No | ❌ No | ✅ Yes |

MBS( "AVRecorder.CaptureStillPhoto"; AVSession { ; FileName } ) 

**MBS**( **"AVRecorder.CaptureStillPhoto";** /\* Captures a still image. \*/  
**$AVSession**; /\* The ID for the AVRecorder session as returned by [AVRecorder.Init](AVRecorderInit.md). \*/   
**$FileName**) /\* Optional; The file name for the jpeg image.e.g. "still.jpg" \*/ 

### Parameters

| Parameter | Description | Example | Flags |
|---|---|---|---|
| AVSession | The ID for the AVRecorder session as returned by [AVRecorder.Init](AVRecorderInit.md). | $AVSession |  |
| FileName | The file name for the jpeg image. | "still.jpg" | Optional |

### Result

Returns image or error.

### Description

Captures a still image.  
The image is returned a JPEG image as container value on Mac and BMP on Windows.  
Added Windows support with plugin version 6.5.  
  
May require running the preview for some time as we capture only current preview frame on Windows. If no frame is yet available, the function returns an error.  
  
If you need content detection, you can always get current frame with AVRecorder.CaptureStillPhoto and pass it to [OCR.SetImage](OCRSetImage.md) for text recognition or [Barcode.Detect](BarcodeDetect.md) to find different barcodes.  
### Examples

Init and Capture photo:

 #Start session   
Set Variable \[$capture ; Value:MBS ( "[AVRecorder.Init](AVRecorderInit.md)" )\]  
\#Pick first video device   
Set Variable \[$r ; Value:MBS ( "[AVRecorder.SetVideoDevice](AVRecorderSetVideoDevice.md)"; $capture ; 0 )\]  
\#Start preview   
Set Variable \[$r ; Value:MBS ("[AVRecorder.StartPreview](AVRecorderStartPreview.md)"; $capture )\]  
\#Wait a bit to have camera get up and running   
Pause/Resume Script \[Duration (seconds): ,5\]  
\#Take a picture   
Set Variable \[$r ; Value:MBS ( "AVRecorder.CaptureStillPhoto"; $capture )\]  
\#Put in container   
Set Field \[test::Test ; $r \]  
\#Cleanup   
Set Variable \[$r ; Value:MBS ( "[AVRecorder.Release](AVRecorderRelease.md)"; $capture )\]  
Take picture and store it in record:

 Set Variable \[ $image ; Value: MBS ( "AVRecorder.CaptureStillPhoto"; $$SessionID ) \]   
\# state of last function in same script: 0 = no error, 1 = got error   
If \[ MBS ("IsError") \]   
 Show Custom Dialog \[ "Sorry" ; $image \]   
 Exit Script \[ Text Result: \]   
End If  
  
If \[ not IsEmpty ( LiveStream::Image ) \]   
 New Record/Request  
End If  
Set Field \[ LiveStream::Image ; $image \]   
Set Field \[ LiveStream::Description ; "Webcam" \]   
Commit Records/Requests \[ With dialog: Off \]  
### See also

- [AVRecorder.Init](AVRecorderInit.md)
- [AVRecorder.Release](AVRecorderRelease.md)
- [AVRecorder.SetVideoDevice](AVRecorderSetVideoDevice.md)
- [AVRecorder.StartPreview](AVRecorderStartPreview.md)
- [AVRecorder.StartQRCodeDetection](AVRecorderStartQRCodeDetection.md)
- [Barcode.Detect](BarcodeDetect.md)
- [IsError](IsError.md)
- [OCR.SetImage](OCRSetImage.md)

### Release notes

- **Version 10.3**
    - Fixed problem on iOS with [AVRecorder.CaptureStillPhoto](https://www.mbsplugins.eu/AVRecorderCaptureStillPhoto.shtml) function.

### Example Databases

- [AVRecorder/AVRecorder iOS Test](https://www.mbsplugins.eu/MBS-FileMaker-Plugin-Examples/AVRecorder/AVRecorder%20iOS%20Test.shtml#10ScriptAnchor_)
- [AVRecorder/AVRecorder](https://www.mbsplugins.eu/MBS-FileMaker-Plugin-Examples/AVRecorder/AVRecorder.shtml#10ScriptAnchor_)

### Blog Entries

- [MBS FileMaker Advent calendar - Door 22 - Taking Photos](https://www.mbsplugins.de/archive/2024-12-22/MBS_FileMaker_Advent_calendar_/monkeybreadsoftware_blog_filemaker)
- [AVRecorder on iOS](https://www.mbsplugins.de/archive/2020-07-16/AVRecorder_on_iOS/monkeybreadsoftware_blog_filemaker)
- [MBS FileMaker Plugin, version 10.3pr9](https://www.mbsplugins.de/archive/2020-07-15/MBS_FileMaker_Plugin_version_1/monkeybreadsoftware_blog_filemaker)
- [Live barcode reading for FileMaker on MacOS and iOS](https://www.mbsplugins.de/archive/2018-08-30/Live_barcode_reading_for_FileM/monkeybreadsoftware_blog_filemaker)
- [MBS FileMaker Plugin, version 6.5pr10](https://www.mbsplugins.de/archive/2016-12-10/MBS_FileMaker_Plugin_version_6/monkeybreadsoftware_blog_filemaker)
- [MBS FileMaker Plugin 6.2 for OS X/Windows](https://www.mbsplugins.de/archive/2016-05-24/MBS_FileMaker_Plugin_62_for_OS/monkeybreadsoftware_blog_filemaker)
- [MBS FileMaker Plugin, version 6.2pr7](https://www.mbsplugins.de/archive/2016-05-07/MBS_FileMaker_Plugin_version_6/monkeybreadsoftware_blog_filemaker)

This function checks for a license.

Created 2nd May 2016 , last changed 9th March 2022

  
[AVRecorder.CanPerformReactionEffects](AVRecorderCanPerformReactionEffects.md) - [AVRecorder.ClosePreview](AVRecorderClosePreview.md)

[HTML Version](AVRecorderCaptureStillPhoto.shtml)