Jump to content
Server Maintenance This Week. ×

Embedding Images Using Applescript


This topic is 5160 days old. Please don't post here. Open a new topic instead.

Recommended Posts

  • Newbies

Hello,

I am trying to create an applescript that will embed an image into a thumbnail field. I currently have a script that "links" an image to the thumbnail field, but I need it to be embedded.

(My script is run from within Filemaker Pro.)

tell application "FileMaker Pro"

set documentID to cell "Doc_ID_D" of current record

set documentIDfile to documentID & ".jpg"

end tell

tell application "Finder"

set thumb_file to "Macintosh HD:Users:moomoo:Desktop:_THUMBNAILS_MASTER:" & documentIDfile as alias

end tell

tell application "FileMaker Pro"

activate

set cell "Thumbnail" of current record to thumb_file

end tell

Thank you!!!

Link to comment
Share on other sites

I don't think AppleScript can embed an image into a FileMaker container field. What you can do is pass the file's path to a global field in FileMaker, coerce the file path to a full FileMaker syntax file path ("imagemac:" & absolute path to file, look in Help or Insert Pictiure dialog to see the syntax), then call a dedicated FileMaker script (whose name must be hard-coded into the AppleScript).

The full AppleScript command to call a FileMaker script is:

do script FileMaker script "the script's name"

Its "scope" is the database level.

Link to comment
Share on other sites

  • Newbies

Thank you so much for your quick reply! You are completely correct in your thinking. After some research, I realized that I didn't need Applescript for the actual "embed photo" command. I ended up finding a way to use Filemaker script with [color:blue]Insert Picture and it's quite simple. In the future, I may use applescript to automate a batch of files and call the filemaker script from within an applescript. Thank you for your help!

For other newbies such as myself, here is the solution that I came up with, which will work on a mac. Basically I have a set of jpg thumbnail files in a directory that are all named with a record ID (example: 0003.jpg, 0004.jpg where 0003 and 0004 are record ID's). I have created a script that anticipates that these files exist in a particular directory. When run, the script automatically embeds a jpg within the currently viewed record.)

In filemaker create a new script:

[color:blue]Set Variable [$thumbfilename; Value:"imagemac:/myvolume//mydirectory/mysubdirectory"&mytable::myrecordID&".jpg"]

Goto Field[mytable::mythumbnailcontainerfield]

Insert Picture["$thumbfilename"]

Also, to be noted: when you use [color:blue]Insert Picture, there is a checkbox option where you can indicate if you want the picture to be embedded or linked. In my case, I checked it off to be embedded. I am somewhat new to filemaker scripting.. it just doesn't seem intuitive to me that there would be a check box option like this. I would expect a way to indicate that within the script text itself, thus my initial confusion.

Edited by Guest
Link to comment
Share on other sites

This topic is 5160 days old. Please don't post here. Open a new topic instead.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.