I need to “extract” information about a picture into a Filemaker 7 database. I need the size of the pictures stored in a field, how do I manage this? I have an old script that supposedly works for filemaker 6 but it doesnt work for Filemaker 7.
tell me
-- Om "Filemaker Pro" måste namnet bytas till databasmotorns namn efter bindning...
try
--ta bildfilpath från fält
set bildfilPath to cell "bildpath" of current record as string
on error
end try
end tell
tell application "Finder"
try
set bildinfo to read file bildfilPath to 500
--FileMaker stödjer inte READ
on error
--Finder fixade inte att läsa filen...
display dialog "Couldn´t find/read the image" buttons "OK"
end try
end tell
tell me
tell database "Bilder.dss"
try
set cell "Bildpath" of current record to bildfilPath as string
set cell "Bildinfo" of current record to bildinfo as string
set cell "Bild" of current record to file (bildfilPath)
-- fungerar bara om filerna har pict preview??
on error
end try
end tell
end tell
I’m really not sure what you are doing in paragraph one of your script, but if you have an image already placed in your database the command you are using will give you the path to the original file you placed into the container for that record. Unless the original file still exists, the rest of your script will not work.
Here is a script where, if the original file exists, you can use “Image Events” to extract all kinds of information about that image. I have included all types that I know of off the top of my head.
set DB_Name to "Bilder.fm7"
set my_file to (choose file without invisibles) as string
tell application "Image Events"
launch
set my_image to open my_file
tell my_image
set the image_properties to the properties of my_image
copy resolution to {the_width, the_height}
set image_type to file type
set color_space to color space
set embedded_profile to embedded profile
set bit_depth to bit depth
set image_path to image file
set image_location to location
set image_class to class
set image_size to dimensions
set image_name to name
end tell
close my_image
end tell
tell document DB_Name of application "FileMaker Pro"
try
set cell "Bildpath" of current record to image_path as string -- path of the image
(* set cell "Bildinfo" of current record to bildinfo as string *) <- insert what info you want
set cell "Bild" of current record to file (image_path) -- inserts the image into record container
end try
end tell