CGImageSource.ThumbnailAtIndex
------------------------------

Creates a thumbnail image of the image located at a specified location in an image source.

| 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.ThumbnailAtIndex"; Ref; Index { ; ImageType; FileName; DesiredSize } ) 

**MBS**( **"CGImageSource.ThumbnailAtIndex";** /\* Creates a thumbnail image of the image located at a specified location in an image source. \*/  
**$Ref**; /\* The image source reference number returned by [CGImageSource.CreateWithData](CGImageSourceCreateWithData.md), [CGImageSource.CreateWithPath](CGImageSourceCreateWithPath.md) or [CGImageSource.CreateWithURL](CGImageSourceCreateWithURL.md) \*/   
**$Index**; /\* The index of the image to query. -1 for global properties. Else a number from 0 to [CGImageSource.Count](CGImageSourceCount.md)-1.e.g. 0 \*/   
**$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" \*/   
**$DesiredSize**) /\* Optional; The desired thumbnail size.  
Default is automatic mode to either return existing thumbnail (if exists in the file) or to create one with 512 pixel width and height.  
If you specify here a different size, we will request to create one with that size.e.g. 512 \*/ 

### Parameters

| Parameter | Description | Example | Flags |
|---|---|---|---|
| Ref | The image source reference number returned by [CGImageSource.CreateWithData](CGImageSourceCreateWithData.md), [CGImageSource.CreateWithPath](CGImageSourceCreateWithPath.md) or [CGImageSource.CreateWithURL](CGImageSourceCreateWithURL.md) | $ref |  |
| Index | The index of the image to query. -1 for global properties. Else a number from 0 to [CGImageSource.Count](CGImageSourceCount.md)-1. | 0 |  |
| 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 |
| DesiredSize | The desired thumbnail size.   Default is automatic mode to either return existing thumbnail (if exists in the file) or to create one with 512 pixel width and height.   If you specify here a different size, we will request to create one with that size. | 512 | Optional      Added in version **14.0**. |

### Result

Returns image or error message.

### Description

Creates a thumbnail image of the image located at a specified location in an image source.  
If the image source is a PDF, this function creates a 72 dpi image of the PDF page specified by the index that you pass.  
Maximum thumbnail size is 512 pixel.  
This function can be used to query previews of various image formats including RAW images. (everything Preview app can also open)  
### Examples

Create a thumbnail:

 Set Variable \[$ref ; Value:MBS ("[CGImageSource.CreateWithData](CGImageSourceCreateWithData.md)"; MyTable::ImageFile )\]  
Set Variable \[$image ; Value:MBS ("CGImageSource.ThumbnailAtIndex"; $ref ; 0; "JPEG"; "thumbnail.jpg")\]  
Set Variable \[$r ; Value:MBS ("[CGImageSource.Release](CGImageSourceRelease.md)"; $ref )\]  
Create thumbnail from a file on disk:

 Set Variable \[ $path ; Value: "/Users/cs/Pictures/IMG\_3625.jpg" \]   
Set Variable \[ $img ; Value: MBS ( "[CGImageSource.CreateWithPath](CGImageSourceCreateWithPath.md)"; $path ) \]   
Set Field \[ test::output ; MBS ( "CGImageSource.ThumbnailAtIndex"; $img ; 0; "JPEG"; "thumbnail.jpg")\]  
Set Variable \[ $r ; Value: MBS ( "[CGImageSource.Release](CGImageSourceRelease.md)"; $img ) \]  
### See also

- [CGImageSource.Count](CGImageSourceCount.md)
- [CGImageSource.CreateWithData](CGImageSourceCreateWithData.md)
- [CGImageSource.CreateWithPath](CGImageSourceCreateWithPath.md)
- [CGImageSource.CreateWithURL](CGImageSourceCreateWithURL.md)
- [CGImageSource.ImageAtIndex](CGImageSourceImageAtIndex.md)
- [CGImageSource.Release](CGImageSourceRelease.md)

### Blog Entries

- [MBS Filemaker Plugin, version 4.3pr2](https://www.mbsplugins.de/archive/2014-07-15/MBS_Filemaker_Plugin_version_4/monkeybreadsoftware_blog_filemaker)

This function checks for a license.

Created 18th August 2014 , last changed 21st December 2023

  
[CGImageSource.SupportedTypes](CGImageSourceSupportedTypes.md) - [CGImageSource.Type](CGImageSourceType.md)

[HTML Version](CGImageSourceThumbnailAtIndex.shtml)