kmoreau893 Posted February 25, 2005 Posted February 25, 2005 I've set up a container field that displays a picture. I'd like another field to display the attributes of the file referenced in that container field. I'm after the resolution pixels tall x pixels wide, and other information if it is available. Is this possible? Thanks for any advice. -Keith
-Queue- Posted February 25, 2005 Posted February 25, 2005 Use a calculation with a text result of GetAsText(containerfield). The first line gives the size (resolution). The other lines give the path in Mac and Windows formats.
Leader Posted February 26, 2005 Posted February 26, 2005 This is why it's good to have Q in your foxhole.
kmoreau893 Posted February 27, 2005 Author Posted February 27, 2005 Thanks very much for the help. I did test out the GetAsText function on a normal container field with a manually inserted picture and I was able to get the resolution as you described. However, I neglected to say that I am using the "image:" directive to display the picture using a calculation field, expressing the result as a container. The formula I'm using to create the image reference is "image:" & "new jpgs/" & product_id & ".jpg". The calculation field I'm using is named "picture_calc" with the output being a 'container'. Therefore when I use the 'GetAsText' function on the 'picture_calc' field, I just get the same evaluated image directive string back, for example "image:new jpgs/2503-1.jpg". Is there a way to get what I want now that I've provided more information? Thanks for all the help. -Keith
Fenton Posted February 27, 2005 Posted February 27, 2005 There is a way to get it with AppleScript (at least in Panther, probably in Jaguar), using the built-in Image Events application (runs in background). This is an example of what it can get (try from Script Editor): set theImage to choose file tell application "Finder" set theName to name of theImage set fileSize to ((size of theImage) div 1024) set creatorType to creator type of theImage -- or "file creator of (info for theImage)" set fileType to file type of theImage as string if fileType is "missing value" then set fileType to name extension of (theImage) end if set theKind to kind of theImage end tell tell application "Image Events" launch set thisImage to open theImage try set theSize to dimensions of thisImage set theHeight to (item 2 of theSize) set theWidth to (item 1 of theSize) set theRes to resolution of thisImage set theDepth to bit depth of thisImage set theSpace to color space of thisImage end try end tell -- bit depth is kind of problematic The problem is then translating the "relative path" you have in FileMaker into a full Mac alias (or file) path (which is what "choose file" returns). This can be done by parsing the database folder path out of Get (filepath), translating it to a Mac path, then adding the relative path (also translated). These can be Unstored (so as not to bloat). myFolder = Substitute( Left(Get(FilePath); Position(Get(FilePath); "/"; 1; PatternCount(Get(FilePath); "/"))); ["/"; ":"]; ["file::"; ""] ) imageFile = myFolder & "images:" & File name field "images:" being the relative folder path (if all images are in the same folder; otherwise use a field). So, setting the file path would look something like this (instead of the choose file line): tell application "FileMaker Pro" -- comment out in FileMaker set imageFile to cell "imageFile" set theImage to imageFile as alias rest of script end tell -- comment out in FileMaker
-Queue- Posted February 28, 2005 Posted February 28, 2005 This is why it's good to have Q in your foxhole. Not to mention Fenton.
Recommended Posts
This topic is 7554 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 accountSign in
Already have an account? Sign in here.
Sign In Now