Jump to content
Sign in to follow this  
Scott Schley

Inserting Pictures into FM Pro

Recommended Posts

How can I insert an image into a FM Pro database using applescript so that the image loads not the reference to the file? The following command will insert a reference to an image.

set cell "Image" to file Test_Image

Thank you.

ss

Share this post


Link to post
Share on other sites

quote:

Originally posted by Scott Schley:

How can I insert an image into a FM Pro database using applescript so that the image loads not the reference to the file?

You need to "Import" the image.

------------------

=-=-=-=-=-=-=-=-=-=-=-=-=

Kurt Knippel

Senior Filemaker Developer

http://www.database-resources.com

mailto:CaptKurt@home.com

=-=-=-=-=-=-=-=-=-=-=-=-=

Share this post


Link to post
Share on other sites

After looking through the FMP Applescript dictionary, if I understand correctly, there is no way for me to import the data from an image file into a FMP field using AppleScript. Is this correct? My understaning is that Import is a FileMaker command that is not scriptable.

Thank you for your help.

Share this post


Link to post
Share on other sites

quote:

Originally posted by Scott Schley:

After looking through the FMP Applescript dictionary, if I understand correctly, there is no way for me to import the data from an image file into a FMP field using AppleScript. Is this correct? My understaning is that Import is a FileMaker command that is not scriptable.

Hmm, I am not a big AppleScript guy, but this could be correct. However you should be able to run a FMP script which has the Import Picture command within it.

------------------

=-=-=-=-=-=-=-=-=-=-=-=-=

Kurt Knippel

Senior Filemaker Developer

http://www.database-resources.com

mailto:CaptKurt@home.com

=-=-=-=-=-=-=-=-=-=-=-=-=

Share this post


Link to post
Share on other sites

quote:

Originally posted by captkurt:

Hmm, I am not a big AppleScript guy, but this could be correct. However you should be able to run a FMP script which has the Import Picture command within it.


The problem with using the Import script step in FileMaker is that you can't specify on the fly what the name of the file is. FileMaker saves the name and location of the file, or presents the user with a dialog to select it. Neither of these solutions may be acceptable to you.

I had a project recently where that was the case. What I came up with was using AppleScript to duplicate the file to be imported and saving it to a known location with a known name, but storing in a variable the original name and location. I then imported the graphic using the Import script step in FileMaker, and also set a text field to the path to the original file.

Chuck

Share this post


Link to post
Share on other sites

Try this:

set cell "ActualPicture" to (file cell "filepath")

Where the filed named "ActualPicture" is a container for the graphic and the field "filepath" text containing the path to the graphic.

If you want some freedom to move the folder full of graphics around, you could set a global with the base of the path upto but not include the file name, then build the final path on the fly.

Share this post


Link to post
Share on other sites

You could use applescript to put a selected file at a designated location and then use the import script step to import the file into FM. A better method is to use a scripting addition to get the PICT data and set the FM field to the PICT data. The result is an internal stored image in FM. Akua Sweets will work, but GraphicsImporter (available at http://osaxen.com/graphicsimporter.html ) will run on OS 9.x and OS X. A sample import script using GraphicsImporter is

Share this post


Link to post
Share on other sites

Tried the GraphicsImporter approach (version 2.2). Works great - thanks for the tip!

Share this post


Link to post
Share on other sites

thanks guys that's wicked, I love this forum!!! smile.gif

tell application "FileMaker Pro"

set theCode to cell "code" of current record of database "images"

set theFilePath to {"Macintosh HD:Users:chris:Desktop:Images:" & theCode}

set the cell "image" of current record to (file theFilePath)

end tell

'code' is filename (it's all based on codes, so we know it'll be code.jpg)

images stored in 'Images' on desktop

filepath created (could be from a global as someone suggests)

set the cell to (file theFilePath) is a v nice way of field based importation. Very quick discreet and efficient. No renaming or random moving. Nice one Clint. I was trying the renaming and moving route before, with FileMakers slower import pic.

Another script I ended up using looked like this (in case someone is needlessly sweating over code, I would have loved more to have been available!):

tell application "FileMaker Pro"

--STICK IMAGE IN FILEMAKER

set theFilePath to cell "TempFilePath" of database "images"

--get tempfilepath which is a global, in this case = Macintosh HD:Users:chris:Desktop:Undone:temp.jpg

set the cell "image" of current record of database "images" to (file theFilePath)

--put image into FileMaker

--RENAME IMAGE BY CODE AND STICK IN DONE FOLDER

set theCode to cell "uniqueID" of current record of database "images" & ".jpg"

--get suffix for the future name of file

set FinalFilePath to cell "FinalFilePath" of database "images"

--get FinalFilePath which is a global, in this case = Macintosh HD:Users:chris:Desktop:Done:

end tell

tell application "Finder"

move file theFilePath to folder FinalFilePath with replacing

set the name of file (FinalFilePath & "temp.jpg") to theCode

end tell

=====

nice one & the looks of that graphicsconverter is just the tick...

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Sign in to follow this  

×
×
  • Create New...

Important Information

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