11 Replies Latest reply on Aug 22, 2012 4:05 PM by philmodjunk

    Creating structure for mobile image database

    NiceData

      Title

      Creating structure for mobile image database

      Post

      [USING FMPRO V10 ON MAC]

      I have been reading about how to "link" to a folder of images so that you don't have embed them in the database and thus keep the file size more manageable. The approach that seems simplest is the method where you create a calculation field where it calculates the image path. 

      I am hoping that someone can help me derive the FMPro syntax to write the formula and create the field. I would like the path to be relative to the database rather than absolute such that I could move the entire directory that houses the databases and images to a thumb drive, to another computer, or simply to another directory on the network...etc and the calculation would hold up. Is this possible in FMPro?

      Let's say the database is stored at the root directory "../ImageCatalog.fp7" and the images live in "../images/" and the image filenames are based on the ID# or barcode field called "NUMBER". So, any particular image's path would be:

      ../images/<NUMBER>.jpg

      Preferably I would like the images to display as a small thumbnail object that when clicked opens the file in the computer's default image viewer.

      Now wondering if someone could walk me through creating the proper field parameters and calculation to achieve this?

        • 1. Re: Creating structure for mobile image database
          philmodjunk

          You don't have to use a calcualtion field for your images, though that is an option.

          If you store the image files in the same folder as your database file, I believe that you can insert them into container fields with the "store a reference" option and they will open on any computer where you place the entire folder containing your database file and image files. (The container fields store a path relative to the database file.)

          • 2. Re: Creating structure for mobile image database
            NiceData

            But by this method you would have to attach each image manually?

            I was hoping to have that automated, as there are going to be thousands of images. 

            • 3. Re: Creating structure for mobile image database
              philmodjunk

              It can be automated.

              A script can export the images to this location and then re-insert them.

              Using a calculation, you might set up something like this:

              let ( [ imageTag = If ( Get ( SystemPlatForm ) = 1 ; "imagemac:" ; "imagewin:" ) ;
                       Fpath = Get ( FilePath ) ;
                       Path = Left ( Fpath ; Position ( Fpath ; "/" ; Length ( fpath ) ; -1 ) ) & "images/"
                     ] ;
                      imageTag & path & Number & ".jpg"
                    )

              This assumes "Number" is a field in your table.

              Note that Export Field Contents can be used to open the image file or this calculation container:

              let ( [ imageTag = "file:" ;
                       Fpath = Get ( FilePath ) ;
                       Path = Left ( Fpath ; Position ( Fpath ; "/" ; Length ( fpath ) ; -1 ) ) & "images/"
                     ] ;
                      imageTag & path & Number & ".jpg"
                    )

              cannot display the image, but it can be double clicked or a script can use Go to Field [select contents] to open the file.

              • 4. Re: Creating structure for mobile image database
                MarcMcCall

                I got this to work with 4 fields

                Container: auto enter Calculation = FilePathCalc

                FilePath: Auto enter Calculation field = GetAsText(Get(FilePath)) & "/images/"

                FilePathCalc Auto Enter Calculation = Substitute(FilePath;"yourfilename.fp7/";"") & FileName  & ".jpg"

                FileName:  text field you enter you photo name in.

                 

                This allows you to have a separate folder called images, in the same location as the DB file.

                • 5. Re: Creating structure for mobile image database
                  MarcMcCall

                  You may want to change the auto enter calculations to straight calculation fields so if you move the file it updates better, this I have not tested.

                  • 6. Re: Creating structure for mobile image database
                    MarcMcCall

                    I just tested, and I would change auto enter fields to calculations, then you will need to create a script to set variable: $FileName Field: FileName, Set Field: FileName Result $FileName to update the Container field with the new filepath.  Of course you would have to first show all records, go to record first, and loop through All records, and exit after last.

                     

                    Of cource this is only if you want to do what you first described.  Now if you want to be able to use various file types, remove the & ".jpg"  and enter the file extention at the end of the file name in the FileName field, and this will allow you to have whateverfile you ente, not just .jpg

                    • 7. Re: Creating structure for mobile image database
                      NiceData

                      Phil, I'm not sure I am able to wrap my head around your methodology. Why the export? Followed by an import? Also, it sort of sounds like I would need to re-run this script every time additions are made to the database. It would be much better if the field just looked in a particular place for the image when the record was called up and displayed. I believe I read that Filemaker can create thumbnails on the fly, but the person saying that didn't explain how to do that. 

                      Marc, This makes sense to me (mostly), although I'm still not familiar with the syntax used. But I'll try this and see what happens. Can you open your files by clicking the field?

                      Thanks

                      • 8. Re: Creating structure for mobile image database
                        philmodjunk

                        Why the export? Followed by an import?

                        The export moves the data into the correct directory (Same directory as database file) and then the insert from this new location updates the file reference to point to it instead of the original location. A script can be written to loop through your database and do this as a one time fix.

                        it sort of sounds like I would need to re-run this script every time additions are made to the database.

                        Unless the user puts the images to be inserted in the correct directory to start, you are correct. But this is also true of the "calculated path" option you've requested.

                        You can set up a similar script to automatically do this on a record by record basis each time you insert a new file. This is a good idea in any case for "by reference" container files as it makes sure that the files are located in the correct location without your users having to concern themselves with knowing the precise location of that folder. They can insert from a file located anywhere.

                        It would be much better if the field just looked in a particular place for the image

                        Yes but then your users all have to consistently place their image files there before they are inserted.

                        Filemaker cannot create thumbnails in fileMaker 10 except when you use the Import Records | Folder tool to import groups of images in a batch operation.

                        Please note that the calculations I posted are an alternative to this scripted approach and are designed to do exactly what you specified then and in your last post.

                        • 9. Re: Creating structure for mobile image database
                          MarcMcCall

                          Yes, I set a script to on record load so it updates automatically.

                           

                          http://www.mediafire.com/?d2vmnxiq79kt4li

                          • 10. Re: Creating structure for mobile image database
                            NiceData

                            Ugh, just typed a long response and it failed to authenticate. I will try to repeat everything...

                            Thank you much Mark for the package you sent. It did everything I wanted except load a thumbnail for browsing the images as well. 

                            Phil, I tried your formula but could not get it to work as a container calculation? Maybe I am supposed to put it somewhere else?

                            ----

                            I figured I would explain the workflow to give more context on how to solve this specific set of problems. 

                            1. Our photog takes pictures and then stores them on the network drive in a folder "Images to be processed".

                            2. Our data entry person goes to this folder of images and image by image logs the metadata into the database while assigning a unique number to each record and to its respective image file name. They then place the logged photos into another network folder within the database directory ../images/.

                            My goals here are two fold (technically three fold):

                            1a.  Automatically link the image file with its respective record. 1b. Automatically populate a thumbnail in the record as well.

                            2. Keep Filemaker file size small by keeping images independent from database, but linked. 

                            The idea is to be able to browse the images from within the database. Right now we have to rely on a file browser to browse the images and a database to look at the metadata, but can't look at both at the same time. Also, we'd like to be able to double click the image link within the database to open up the full resolution image to see more detail when necessary. 

                            Marc's solution he sent does everything except the thumbnails. So I'm almost there. Thanks

                            • 11. Re: Creating structure for mobile image database
                              philmodjunk

                              2) I'd use the import Records | Folder tool to do this. It's quicker and you can get the thumbnails that you want. This can be scripted so that the user clicks a button a gets a list of container fields images, and file names where they can then update other fields in the same records to enter the "metadata".