Jump to content
Claris Engage 2025 - March 25-26 Austin Texas ×

This topic is 5499 days old. Please don't post here. Open a new topic instead.

Recommended Posts

Posted

Is there an easy way to export images from a container field directly to a folder? I'm referring to exporting either from a database with embedded images (non-referenced), or exporting a subset of images from a database that references its images to a separate folder.

Posted (edited)

Thank you.

I have a catalog of 300 individual manta rays. The parent table named "catalog" has 300 records, one for each individual with only the best photo of each individual showing. The child table has multiple images of each individual from various encounters, with only one flagged as the primary photo. I want to export the field contents (Images) from the container field in the parent table (the 300 best images) to its own folder (this folder will be uploaded to the web as the reference folder for the main catalog of individuals). Using the script "export field contents", it prompts for the new filename and location of the exported image, but it only does so for the record being browsed (i.e. one record at a time). Is there a way to do all the parent records at once keeping the filename the same as the original in the export folder?

I guess I should explain the whole objective here. My current manta ray database contains 300 individuals (parent table) but each individual has multiple encounters (child table). The child table has several photos for each individual while the parent table shows only the best photo, the one designated as the primary. I wish to put this catalog on the server for others to search through when they encounter a manta ray in order to match theirs to individuals in the catalog. I don’t want to upload the entire database since it includes over 1500 photos, I simply want to upload the parent table containing the one primary (best) photo for each individual. In order to do this, I exported the parent table to new database, which contains the UniqueID, BestPhoto, and an IndividualAttributes field. The BestPhoto container field references the folder with all 1500 images but I don’t want to upload this entire folder to the server. So my thinking was to “export field contents” of the BestPhoto field to a new folder, preferably not one record at a time but all records at once with one script, while keeping the exported image names the same. Since I will want to relink my BestPhoto field in the database to the exported images folder, I may need to store the reference path to the exported images somewhere in a new field (NewPath). Then somehow switching the reference of my BestPhoto field from the old path (from to the folder with 1500 images) to the new path (folder with only 300 images). Once complete, I should be able to upload the new database with the new reference image folder. I hope this makes sense. Any suggestions to do this would be appreciated.

Edited by Guest
Clarifying overall objective
Posted

The basic technique is Find your records with the "best" mark. You can do this manually or scripted. Then run a script to Loop thru the records. On each one it will use the Set Variable command to set the FileMaker syntax folder path & the file name. The Export Field Contents will use this to export the container field as a uniquely named file (the file names would need to be unique, or you'd get an error if you're using only one folder as the target).

Container_Export_DT_Loop.fp7.zip

Posted (edited)

Your script works like a charm.

Now all I need to do is change my embedded photos to reference the new "pictures" folder (essentially match the filenames and create a link instead of an imbedded photo. Any suggestions of doing this switch?

Edited by Guest
Posted (edited)

There are 2 easy ways to do this. The first is to include this in the operation. So it Export Field Contents, then immediately re-insert that file as [x] Reference only.

The 2nd way, which I would recommend, is to not bother to re-inserted them.* You can just create a calculation which produces the FileMaker syntax path to the picture. The result type of the calculation is "Container" (not Text, seems weird but required), storage "Do not store" (I doubt if it could anyway).

See example file. There are 2 layouts, each showing a method. You have to run the Export first, to put the picture files into the Pictures folder on your Desktop. It will also re-insert them. You will also see the picture on the "calculation" layout.

Then, as a test, go to the original layout and delete the referenced picture. Then go look again at the calculation layout. The picture still shows there. Because it is calculated from the path to the folder and the file name (need that). One advantage of this method is that if you decide to change that path slightly, you can just change the calculation and everything still works.

*Well, since the script already re-inserted them, you would need to change that part of it. Or have both methods. There is no conflict between them. And neither is stored, so it makes little difference. You could also just add the calculation to your existing file. All it needs is the folder path (in the calculation) and the file name (which is in a field).

Container_embed_to_ref.fp7.zip

Edited by Guest
Posted (edited)

Thanks Fenton.

Would you mind checking my script code for the last script? Can't seem to get it to work.

I was able to do the image link in a much less sofisticated way. Once the images were exported to the pictures folder, I opened a new database, did an "import folder" of the images folder, and since one field during import is filename, I used that to match records with my other database and import as a reference file. However, I prefer to use your method since I will likely be moving folders breaking file paths and so tweaking the path in the script would be an easy fix.

Thanks, Mark

MantaRayCatalogFullWorking3a.fp7.zip

Edited by Guest
Posted

What is wrong with the "Export Embedded to DT, Import as Reference Loop" script is that you're trying to Insert into a calculation field; which cannot be done. What you would need to do is to Insert back into the Embedded Photo field (which is then no longer an "embedded" field).* The idea of that script is to "swap" the embedded photo to a referenced photo.

I'm not sure which method you mean when you say "your method" (as there are kind of 2 of them, and you may only need 1 of them). But if you're going to use the calculation method to show the photos, then all you need is the file name. AND a consistent folder structure which can be calculated for EVERY photo file.

Of course you can include different folder paths also, if you have that data in a field. You can even use only the drive name as the fixed part of the calculation. But usually the method is for situations where much of the folder structure is known already.

*One reason why my file just has "Container" as the field name, as it serves both purposes. Swapping embedded and referenced is a little confusing, since the result looks the same, until you look at GetAsText() or Length().

Posted

So now I am ready to upload the database to the server. The path to my images folder on the server is:

http://mantacatalog.fmgateway.com/images/

so how can I reset the path reference of my images, which currently directs to my desktop folder, to the new folder, which is a copy of my images folder? I have to do this before uploading to the server since I can't run the scripts on the server.

Posted

Since that is a URL path, not a FileMaker nor OS syntax path, it might be best to just create a calculation in a Web Viewer that resolves to that path & the file name. I didn't realize the files were going to be on a hosting service. But it does not much matter. A Web Viewer will show them fine.

Posted (edited)

Thanks but I'm not sure how to create the calculation for the Web Viewer. I created a global storage text field that has the URL for the images folder on the server (http://mantacatalog.fmgateway.com/MantaImagesLowRes/) and I have a second text field that has the unique filename of the image belonging to each record (e.g: 1001L01S108S3.JPG). How can I combine the two to direct the Web Viewer to go to that URL and display the proper image from that folder?

Edited by Guest
Posted (edited)

I guess the solution is quite easy, create a web viewer, double click the viewer in layout view to open the web viewer setup, paste the following in the URL:

"http://mantacatalog.fmgateway.com/MantaImagesLowRes/" & Mantas::Filename

Problem is that the web viewer does not resize images to fit the viewer so if you have different sized images, you end up with a mess. Best to batch process all the images to the size of the viewer.

Edited by Guest
Posted

You can also add an image size to the calculation for the image file in the Web Viewer, and it will dynamically resize what it shows. This example file will resize an image file which was Inserted as reference. Your calculation, for an image URL would be simpler. But it's late, so I'll send what I've got.

WebViewer_data_image-resize.fp7.zip

Posted

Thanks fenton.

One of the problems with batch processing all the images to make them the same size to fit in the viewer is that some of the images are .jpg and others are .tiff, and so all the .tiff files get converted to .jpg during the batch and I lose my file links due to the extension change.

The WebViewer calculation you sent me works well on my local computer but when I insert a URL path instead of a local file path to my images folder, it no longer works. Is there a way to do it with a URL reference? Here is the current Web Viewer code but the img src doesn't seem to be working with that URL reference:

Choose ( Abs ( Get ( SystemPlatform ) )-1 ; "Data:text/html," ; "About:" )

&

"MantaImagesLowRes"

Posted

Here is a link to a post with a better example file, by comment. I should have looked for it earlier; I knew I'd seen it somewhere...

http://fmforums.com/forum/showpost.php?post/289984/

This topic is 5499 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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.