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

Converting image file references to the actual images in a container field


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

Recommended Posts

Posted

I have a database of 300 individuals, each record having a photograph of the individual in a container field. The image is not embedded in the database but simply linked through a file path. I want to publish this database to a server but before I do that I want to convert the individual photo links to the actual images before I upload. Is there an easy way?

Posted

First, I moved your other post to the ScriptMaster forum. Could you please Delete those posts, before others waste time answering them? Maybe they already have though.

Anyway, it is easy to do, as you already have the path you need. It is the last line of the "text" of the container field. First set that into a script Variable, then use that to Insert into the container field (with [x] As reference unchecked in the Insert step). Or into another container field, to be safe; though you'd then need to switch the field on the layout(s).

Set Variable [ $image_path; Let ( txt = GetAsText ( container field ); GetValue ( txt; ValueCount (txt))) ]

Insert Picture [ container field; $image_path ]

Try it on one, then run it in a Loop script, on the found set.

Hopefully these are small images (always). Otherwise you should pre-process the images to a small size. Or put them into another FileMaker file, just for the images, so as not to bloat your main file. It makes a difference when you set up backup routines, or need to transfer the file.

Posted (edited)

Well, you sure make it look easy but with my limited skills in scripting, I'm having difficulty. My container field has no text, just the image but the image is linked so it must have an image path somewhere, I just can't see it anywhere. Nonetheless, I have a separate text field that does show the image path for each photo, which means I shouldn't need to do the Set Variable script? I tried just doing the Insert Picture command using my photo container field and my image path field, but no luck.

Edited by Guest
Posted (edited)

Your container field does have the "text", but it uses it internally to store the path to the image (its dimension, its relative path, and its absolute path, 3 lines). It shows you the image of the referenced file, not the text it is storing. Create another calculation field, with the calculation: GetAsText ( container field ), result type of Text, and you'll see the text.

The trouble with the path you're storing in your field is likely that it is not a FileMaker syntax path; it is likely an OS path (Mac or Unix syntax). Which is fine and dandy, if you wanted to access the file as a file with some other tool; but will not work as is for Insert. The 3rd line of GetAsText (container field) will work, as it IS the FileMaker syntax path to the file.

With file paths both syntax and accuracy matter (don't ask how I know :-). Nothing else works.

You must use the Set Variable step, because the Insert command will only accept 2 things (either of which has to be, or evaluate to a FileMaker syntax path):

1. A hard-coded text path (which will not work, as you want it different for each record).

or

2. A script variable, pre-set to the path

It will not accept FileMaker calculations. It's annoying that way.

Container_ref_to_embed.fp7.zip

Edited by Guest
added file
Posted

Set Variable [ $image_path; Let ( txt = GetAsText ( container field ); GetValue ( txt; ValueCount (txt))) ]

Insert Picture [ container field; $image_path ]

Ok, I understand the GetAsText function and I used it in a new field to show the container image path.

In building the script, I am able to set the variable code:

Set Variable [$image_path; Let ( txt = GetAsText (Mantas::Photo); GetValue (txt; ValueCount (txt)))]

But can't seem to get the Insert Picture script in the proper format. I choose the Insert Picture script, click on specify, and type in:

Mantas::Photo; $image_path

but returns an error to please correct syntax of the file path?

Posted

Since Fenton's offline, and you're here deakos, I'll chime in.

You need Go to Field (container)

and then

Insert Image ( )

and then type the word image:$image_path into the Specify Picture File dialog.

Posted

Oops, sorry. I forgot to add the Go To Field [ container ] when I wrote that (I sometimes forget it in real life also). But it is in the example file I uploaded later.

It is hard at first to get used to using ONLY a $variable name in a dialog. But resist the idea that you can do calculations there; do all calculating beforehand, when you Set Variable.

Posted

Thanks for helping out. My script thus far looks like this:

Set Variable [$image_path; Let ( txt = GetAsText (Mantas::Photo); GetValue (txt; ValueCount (txt)))]

Go to Field [Mantas::Photo2]

Insert Picture["$image_path"]

When I run the script I get the following error:

"The file "$image_path" could not be found and is required to complete this operation"

Posted

Fenton,

I imported your script into my database and it worked fine. I can't say I necessarily understand the code, but I guess that is why I'm at this end of the dialogue and you are at that end. The important thing is that it works. Thanks for your help. Mark

This topic is 5510 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.