Components All New MacOS Windows Linux iOS
Examples Mac & Win Server Client Guides Statistic FMM Blog Deprecated Old

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 3.4 ✅ Yes ❌ No ❌ No ✅ Yes, on macOS ✅ Yes
MBS( "CGImageSource.ThumbnailAtIndex"; Ref; Index { ; ImageType; FileName; DesiredSize } )   More

Parameters

Parameter Description Example Flags
Ref The image source reference number returned by CGImageSource.CreateWithData, CGImageSource.CreateWithPath or CGImageSource.CreateWithURL $ref
Index The index of the image to query. -1 for global properties. Else a number from 0 to CGImageSource.Count-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 Available in MBS FileMaker Plugin 14.0 or newer.
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

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"; MyTable::ImageFile)]
Set Variable [$image; Value:MBS("CGImageSource.ThumbnailAtIndex"; $ref; 0; "JPEG"; "thumbnail.jpg")]
Set Variable [$r; Value:MBS("CGImageSource.Release"; $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"; $path ) ]
Set Field [ test::output ; MBS( "CGImageSource.ThumbnailAtIndex"; $img; 0; "JPEG"; "thumbnail.jpg")]
Set Variable [ $r ; Value: MBS( "CGImageSource.Release"; $img ) ]

See also

Blog Entries

This function checks for a license.

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


CGImageSource.SupportedTypes - CGImageSource.Type