August 26, 200520 yr 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 August 26, 200520 yr by Guest
August 27, 200520 yr 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
Create an account or sign in to comment