6 Replies Latest reply on Nov 8, 2012 8:36 AM by philmodjunk

    Accessing attributes of images saved in Filemaker Pro



      Accessing attributes of images saved in Filemaker Pro


           Hi everybody,

           Does anyone know of a way in FileMaker to get the attributes of an image after it’s been pasted into a container field?

           As developer and administrator of a shared contact database, I would like to constrain the dimensions of the images that other users add to the records. I would also like FileMaker to track whether they are color or grayscale images, check the image format type, and be able run calculations on any of this data, So far, I’ve not been able to find any function inj FileMaker Pro 10 or FileMaker Pro 12 Advanced that would allow me to query an image let alone the contents of a container field.


           The following should give you a better idea of how I intend to apply such a capability.

           In a step-by-step example, I might set up a layout so that the only way to save an image with a record is to

      1.           Paste it into a big global field,
      3.           Press a SAVE BUTTON, which in turn runs a script preceeded by a validaton sub-routine that checks:

      If certain attributes of the image falls within certain preset value ranges (i.e., width and height in pixels, size of the image in KB; the image's format type, and whether the image is in color or grayscale),

      then, the script moves (cuts & pastes) the image from the global field to its destination container field, its steps are committed, and it displays a custom dialog confirmirming that the image was saved. The message box includes an OK button which removes itself and exits the script .

      else it displays a custom dialog  error message explaining which attributes are out of range, does not move the image nor commit any changes. The message boix includes an OK button which clears the global field. re,moves itself and exits the script.

           Unless FileMaker can easily do this all on the fly, I might need to store the data when images pass validation so that later, I may query and apply math functions on the data. 


      A couple questions that came up as I was creating this post.

      1.           Will I need and be able to include something like Javascript in my script?
      3.           Could QuickTime Pro be of any help? in addition to AV and multimedia formats, I undedrstand that QuickTime and QuickTime Pro 7 supports JPEG, PNG, PICT and TIFF, ss well as work well with FileMaker.

           Any comments or suggested alternatives would be greatly appreciated

      FMPro 10.0v3
           FMPro 12.0v2 Advanced
           - -
           Mac OS 10.7 (Lion)
           Windows XP Professional SP2
           Microsoft Windows Network
           Multi-plaform environment


        • 1. Re: Accessing attributes of images saved in Filemaker Pro

               Some, but not all of what you want can be done natively in FileMaker. I'd look for a plug in to see if one offers the additional info you want on image files in container fields.

               You can access the pixel dimensions (A x B) of an image in a container field, if Insert Picture with the store a reference option enabled is used to insert a reference to the image file into a container field. If that specific insert method is used, GetValue ( ContainerField ; 1 ) will return those dimensions.

               On the other hand, Length ( ContainerField ) will return the size of the image in Bytes if the image is NOT inserted with the store a reference option enabled.

               Thus, the byte size of the image file can be accessed immediately after pasting the image into the container field and a script can use export field contents to export the file and then re-insert it with the "store a reference" option enabled so that it can then extract the pixel dimensions.

               But the rest of the info on your image is not accessible via native FileMaker functions--look for a plug in for those.


          then, the script moves (cuts & pastes) the image from the global field to its destination container field,

               This is not the best way to move data (whether an image file or any other kind of data) from one field to another. Set Variable and Set Field can be used to move data from field to field without using the clipboard and thus leaving any copied data by the user unmodified. (Though in this case, since the image was pasted from the clipboard, the image data is already there to be paste.) Using set Variable and set Field to move data also works even if the fields referenced by them are not physically present on the current layout where copy/paste steps will silently fail to work if the fields they reference are not on the current layout.

          • 2. Re: Accessing attributes of images saved in Filemaker Pro

                 SuperContainer Plugin  http://www.360works.com/supercontainer/

                 Comparison Chart   http://www.360works.com/supercontainer/comparison_chart/

                 $195.00: Workgroup license  up to 10 people

            • 3. Re: Accessing attributes of images saved in Filemaker Pro

                   Hi Phil,

                   Thank you, this is great to know. This will work for any new images that users save in the database.

                   Now what if there are existing images already in a FM Pro container field? Is their any way to get those pixel dimensions and file sizes?

                   It appears that the FM Pro native solution is dependant on using the INSERT > Picture command which seems to require a path to a single image file. It would be impractical to copy each existing image from it's record and resave it in some image editing program as a JPEG. PNG, PICT, etc. and then reinsert it via scripting.



              • 4. Re: Accessing attributes of images saved in Filemaker Pro

                     Why would you need to use an image editing program for this?

                     FileMaker scripts can export and re-insert files for you. Please note that file size is accessible for any inserted file that is not inserted "by reference". Pixel dimensions are only available if insert picture is used to insert the image file "by reference". I can't tell you if this is practical for your database or not, but you can define two container fields, use one for a by reference, Insert Picture insert of the file and another for an "embedded" insert of the file.

                     Once you have captured the needed data from the container field into other fields, you can clear one or the other container field if it is no longer needed. Clearing the "embedded" container field would significanly reduce the size of your database file.

                • 5. Re: Accessing attributes of images saved in Filemaker Pro

                       Thanks Phil,
                       You're right, I don't need an image editing program. However, I'm since my last posting I've been trying to implement the solution you suggested but to no avail. I've not been successful using the Export Field Contents script step. Perhaps I'm not clear on the file path concept or something else.

                       With over 600 embedded images, the FM Pro database is now over 10 GB. The images are of various types such as jpg, png, pdf, etc., although I have no way of knowing which type each of them are.

                       I would like to automate the following:

                  1.           Export all the images from my FMPro database, 
                  3.           Save all images in one directory (with a unique filename base and the filename extension automatically derived from the image's file type,
                  5.           Delete the images in the database,
                  7.           Reinsert each image using a reference from the database record to the corresponding file, and then
                  9.           Perform my original operation           
                    1.                     Capture the image dimensions and file size as you outlined above, and
                    3.                     Delete the temporarily embedded images.

                       The only way I could get FMPro to reveal the file's image format type, is to not specify the output file when Export Field Contents is run. (It'll show up in the Save dialog box as "untitled.XXX", whereas "XXX" is the image file type's extension.) However, this seems to leave me without a way to specify the filename's base and a path to the directory.

                       Can you please tell me if this can be done natively in FM Pro and how, or will it require a plug-in?

                       Also, would you happen to know where I can find documentation about this or some good examples?

                       Again, your help is greatly appreciated.

                  • 6. Re: Accessing attributes of images saved in Filemaker Pro

                         The following script exports and re-inserts files from a container field for all records in the table. Step 3 in your list is not needed as the re-insert will overwrite the original data, the embedded file.

                         Freeze Window
                         Show All Records
                         Go To Record/Request/Page [First]
                         Set Variable [$DirectoryPath ; value: Get ( DesktopPath ) & "ImageFiles/"]---> This requires that a folder named "ImageFiles" be located on your desktop
                            Set Variable [$FileName ; value:
                                                   Let ( [T = GetAsText ( GetValue ( YourTable::containerField ; ValueCount ( ContainerTest::containerField ) ) ) ;
                                                            L = Length ( T )];
                                                            Right ( T ; L - Position ( T ; "/" ; L ; -1 ) )
                            Set Variable [$Path ; Value: $DirectoryPath & $FileName ]
                            Export Field Contents [ YourTable::YourContainerField ; “$Path” ]
                            Go To Field [ YourTable::YourContainerField ]
                            Insert Picture [Reference ; $Path ]
                            Go To Record/Request/page [next ; exit after last]
                         End Loop

                         The calculation shown in blue is part of the Set Variable [ $FileName step and will extract the file name for the file in the container field that was originally inserted by any method except Insert Object. It will work for the inserted files whether or not "store a reference" was originally specified.