AVAsset.Image
-------------

Returns an image for the asset at or near a specified time.

| Component | Version | macOS | Windows | Linux | Server | iOS SDK |
|---|---|---|---|---|---|---|
| [AVAsset](component_AVAsset.md) | [5.2](newinversion52.md) | ✅ Yes | ❌ No | ❌ No | ✅ Yes, on macOS | ✅ Yes |

MBS( "AVAsset.Image"; Asset; Time { ; ImageType; FileName; Width; Height } ) 

**MBS**( **"AVAsset.Image";** /\* Returns an image for the asset at or near a specified time. \*/  
**$Asset**; /\* The reference number of the asset. Please use [AVAsset.OpenContainer](AVAssetOpenContainer.md), [AVAsset.OpenFile](AVAssetOpenFile.md) or [AVAsset.OpenURL](AVAssetOpenURL.md) function to get asset reference. \*/   
**$Time**; /\* The position in the video in seconds.e.g. 5.2 \*/   
**$ImageType**; /\* Optional; The type of image to return.   
Either JPEG, PNG, GIF or BMP. Default is JPEG.e.g. "JPEG" \*/   
**$FileName**; /\* Optional; The filename to use for the picture.   
Default is "image" with the extension matching the image type.e.g. "test.jpg" \*/   
**$Width**; /\* Optional; The maximum width to use.e.g. 500 \*/   
**$Height**) /\* Optional; The maximum height to use.e.g. 500 \*/ 

### Parameters

| Parameter | Description | Example | Flags |
|---|---|---|---|
| Asset | The reference number of the asset. Please use [AVAsset.OpenContainer](AVAssetOpenContainer.md), [AVAsset.OpenFile](AVAssetOpenFile.md) or [AVAsset.OpenURL](AVAssetOpenURL.md) function to get asset reference. | $asset |  |
| Time | The position in the video in seconds. | 5.2 |  |
| ImageType | The type of image to return.    Either JPEG, PNG, GIF or BMP. Default is JPEG. | "JPEG" | Optional |
| FileName | The filename to use for the picture.    Default is "image" with the extension matching the image type. | "test.jpg" | Optional |
| Width | The maximum width to use. | 500 | Optional |
| Height | The maximum height to use. | 500 | Optional |

### Result

Returns container value with image or error.

### Description

Returns an image for the asset at or near a specified time.  
The time may not exactly be possible, so a nearby frame may be picked.  
You can call [AVAsset.RequestImageTimePrecision](AVAssetRequestImageTimePrecision.md) before to request exact timings for images. Query [AVAsset.ImageActualTime](AVAssetImageActualTime.md) function to see which time the image was created from.  
  
If you need this functionality on Linux or Windows, you can use [Shell](component_Shell.md) functions and run ffmpeg command line to extract a frame for you.  
### Examples

Queries image at 5 seconds:

 MBS ( "AVAsset.Image"; $asset ; 5; "jpeg"; "preview.jpg")  
Make a preview from video:

 # try video via [AVAsset](component_AVAsset.md) functions   
If \[ $CouldBeVideo \]   
 Set Variable \[ $asset ; Value: MBS ( "[AVAsset.OpenContainer](AVAssetOpenContainer.md)"; $input ) \]   
 If \[ MBS ("IsError") = 0 \]   
 Set Variable \[ $image ; Value: MBS ( "AVAsset.Image"; $asset ; 10; "jpeg"; "preview.jpg") \]   
 If \[ MBS ("IsError") = 0 \]   
 Set Field \[ Get Preview::Preview ; $image \]   
 Set Field \[ Get Preview::Made using ; "AVAsset" \]   
 Set Variable \[ $r ; Value: MBS ( "[AVAsset.Release](AVAssetRelease.md)"; $asset ) \]   
 Exit Script \[ Text Result: \]   
 End If  
 Set Variable \[ $r ; Value: MBS ( "[AVAsset.Release](AVAssetRelease.md)"; $asset ) \]   
 End If  
End If  
### See also

- [AVAsset.ImageActualTime](AVAssetImageActualTime.md)
- [AVAsset.OpenContainer](AVAssetOpenContainer.md)
- [AVAsset.OpenFile](AVAssetOpenFile.md)
- [AVAsset.OpenURL](AVAssetOpenURL.md)
- [AVAsset.Release](AVAssetRelease.md)
- [AVAsset.RequestImageTimePrecision](AVAssetRequestImageTimePrecision.md)
- [IsError](IsError.md)
- [QTMovie.FrameImageAtTime](QTMovieFrameImageAtTime.md)

### Example Databases

- [Containers/Create Container Preview](https://www.mbsplugins.eu/MBS-FileMaker-Plugin-Examples/Containers/Create%20Container%20Preview.shtml#1ScriptAnchor_)
- [iOS/Examples/Movie Container iOS and Mac](https://www.mbsplugins.eu/MBS-FileMaker-Plugin-Examples/iOS/Examples/Movie%20Container%20iOS%20and%20Mac.shtml#4ScriptAnchor_)
- [Mac only/Movies/AVAsset Test](https://www.mbsplugins.eu/MBS-FileMaker-Plugin-Examples/Mac%20only/Movies/AVAsset%20Test.shtml#1ScriptAnchor_)

### Blog Entries

- [Combined Components with MBS FileMaker Plugin](https://www.mbsplugins.de/archive/2021-03-29/Combined_Components_with_MBS_F/monkeybreadsoftware_blog_filemaker)
- [MBS FileMaker Plugin 5.2 for OS X/Windows - More than 3200 Functions](https://www.mbsplugins.de/archive/2015-08-04/MBS_FileMaker_Plugin_52_for_OS/monkeybreadsoftware_blog_filemaker)

This function checks for a license.

Created 19th June 2015 , last changed 15th April 2023

  
[AVAsset.HasProtectedContent](AVAssetHasProtectedContent.md) - [AVAsset.ImageActualTime](AVAssetImageActualTime.md)

[HTML Version](AVAssetImage.shtml)