Create Thumbnail |
Creates a thumbnail (a small image of normally 80×80 pixels) from a graphics file and returns it.
Syntax
Create Thumbnail [ Select ; Thumbnail ; FilePath ; Thumbnail Name ;
Thumbnail size ; Make Square ; Thumbnail Type ]
Options
Select entire contents | replaces the contents of a field with the result. If not checked the result replaces the currently selected portion of the field |
Thumbnail | field or variable where to store the created thumbnail |
FilePath | the path to the file from which to create a thumbnail |
Thumbnail name | the (internal) name of the created thumbnail |
Thumbnail size | maximum size of the height or width (in pixels) |
Make Square | create square thumbnails (the extending parts of the wider side of the image are cropped) |
Thumbnail Type | create a JPEG or a PNG. Use a PNG thumbnail if you want the same transparent areas as the original |
Returned Result
Data type returned
Container
Result
The returned result is the thumbnail itself. If an error occurs an error code is returned. An error always starts with 2 dollars, followed by the error code. You should always check for errors. Returned error codes can be:
$$-2003 | cantFindHandler | no thumbnail could be created |
$$-8994 | noThumbnailFoundErr | the file has no embedded thumbnail |
Other errors may be returned.
Originated in
Troi File Plug-in 9.0
Compatibility
FileMaker Pro 17 to FileMaker Pro 21 (2024)
Considerations
The “Make Square” option will create square thumbnails. In this case the thumbnails will have the extending parts of the wider side of the image cropped (thus showing the middle square of the image). Also note that the image will be scaled proportionally up to a square, if one of the sides of the image is smaller than the requested size. This makes sure the result is always a square with the exact dimensions requested.
The optional thumbnailName is added to the created thumbnail image data and also when the thumbnail is stored in the container. This name is normally not visible, but will be used for example when you perform a Export Field Contents action later.
You can also use FileMaker styled paths, like “imagemac:/MacHD/folder/myImage.jpg”.
An error code $$-2003 is returned when you try to create a thumbnail for a file that has no graphics, for example a text file or a spreadsheet. It is no problem if you don’t know if a file has a thumbnail. Just try to create a thumbnail, if you get the error $$-2003 you know it is not possible.
Starting with v13.0 you can create thumbnails from PDFs, also on Windows (64-bit only).
Starting with v13.0 you can create thumbnails from a container field (or a variable with container data), for example a JPEG or PDF in a container field.
The plug-in can sometimes return error code $$-8994 (noThumbnailFoundErr) instead of the expected $$-2003.
Example
Create Thumbnail [ Select ; container field ; "Mac HD:photo.jpeg" ]
This will create a thumbnail and put it in a container field.
Example 2
Say you want to create the thumbnails of file paths that are stored in a set of records. We assume that in your FileMaker file the following fields are defined:
gErrorCode Global, number
filePath text, contains the path to a file
thumbnailField container
filePath should contain the full path to existing files, for example “Mac HD:Aap.JPG” (Mac). In a script add the following script steps:
Go to Record[ first ]
Loop
Create Thumbnail [ Select ; thumbnailField ; filePath ]
Set Field [ gErrorCode ; GetAsText ( thumbnailField ) ]
Exit Loop If [ Left ( gErrorCode ; 2 ) = "$$" ) ]
Go to Record [ next, exit after last ]
End Loop
This will try to create thumbnails for all files for the records of the found set.
Related functions
TrFile_CreateThumbnail |
TrFile_GetIcon |
TrFile_ListFolder |
Related topics
Troi File Plug-in online help (overview)