Create Thumbnail (script step reference)

By May 1, 2017 May 22nd, 2019 Online Help, Troi File Plug-in
Troi File Plug-in for FileMaker Pro

Create Thumbnail

Creates a thumbnail (a small image of normally 80×80 pixels) from a graphics file and returns it.

SyntaxScript step badge

Create Thumbnail [ Select ; Thumbnail ; FilePath ; Thumbnail Name ;
                   Thumbnail size ; Make Square ; Thumbnail Type ]

Options

Select entire contentsreplaces the contents of a field with the result. If not checked the result replaces the currently selected portion of the field
Thumbnailfield or variable where to store the created thumbnail
FilePaththe path to the file from which to create a thumbnail
Thumbnail namethe (internal) name of the created thumbnail
Thumbnail sizemaximum size of the height or width (in pixels)
Make Squarecreate square thumbnails (the extending parts of the wider side of the image are cropped)
Thumbnail Typecreate 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:

$$-2003cantFindHandlerno thumbnail could be created
$$-8994noThumbnailFoundErrthe file has no embedded thumbnail

Other errors may be returned.

Originated in

Troi File Plug-in 9.0

Compatibility

FileMaker Pro 16 to 18

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.

Currently 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 functionsFunction badge

TrFile_CreateThumbnail
TrFile_GetIcon
TrFile_ListFolder

Related topics

Troi File Plug-in online help (overview)


Online Help Page for Troi File Plug-in for 14 to 18 –> Create Thumbnail (filep7284) 2019-0522 16:33:38