Jump to content
Claris Engage 2025 - March 25-26 Austin Texas ×

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

Recommended Posts

Posted (edited)

Is it possible with Applescript (or any other way) to embed an image into a database.

I have run scripts that place an image into a container,

but this is only a reference to the image.

For example:

set folderPath to choose folder

tell application "FileMaker Developer"

activate

repeat with i from 1 to count of records

tell record i

set pictureFileName to cell "Ad Number" & ".pdf" as string

try

set cell "Picture" to file (folderPath & pictureFileName as string)

end try

end tell

end repeat

end tell

activate

display dialog "Done"

Edited by Guest
Posted

When you use: file (file path)

you are inserting as a reference, because it's a file, not the actual image in the file. You need some way to get the image out. In the past I've used the GraphicsImporter OSAX (Scripting Addition) to do this.

http://osaxen.com/files/graphicsimporter2.2.html

Put it in your Home/Library/Scripting Additions/ folder. Or in the System/Library/Scripting Additions/ folder.

It has a few limitations however. It is very good for creating a custom sized jpeg for example and inserting as a thumbnail. It is not so good for PDFs, etc.. In that case I'd recommend using AppleScript to move/rename the file to a fixed accessible location, then using the Insert Picture command from FileMaker. It works better for PDFs.

Here is the AS using it. [The "¬" symbol below is the AppleScript soft return, option-return keys, for a line continuation. Don't know what this web app will do to it.]

set isImage to false

tell application "Finder"

set FileRef to (choose file with prompt "Choose the PDF or Image file to Insert…")

set FileInfo to (info for FileRef)

set fileType to file type of FileInfo

set FileName_ to name of FileInfo

set ext to name extension of FileInfo

if {"GIFf", "JPEG", "PICT", "TIFF", "PNGf", "PDF "} contains fileType or ¬

{"gif", "jpg", "pct", "tif", "png", "pdf"} contains ext then

try

set theImage to giconvert theFile

set isImage to true

on error

display dialog "Error. Either the file is not an image, or you don't have the GraphicsImporter OSAX" buttons {"Cancel"} default button 1 with icon stop

return

end try

end if

end tell

--tell application "FileMaker Developer"

activate

if isImage is true then

tell current record of window 1

set cell "FileName_" to FileName_

set cell "File_" to theImage

set cell "FilePath_" to (FileRef as Unicode text)

end tell

end if

--end tell

This topic is 7027 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.