Jump to content
View in the app

A better way to browse. Learn more.

FMForums.com

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Get file size from container field

Featured Replies

  • Author

Hi,

I have searched the forums for how to do this, but I couldn't find the answer. Sorry, if it's been posted and I just missed it.

I am making a simple document library, and I want to display the size of files imported into my container field (named 'Image'). I have tried GetAsText(Image), but all it returns is the file name. From other posts, I know that people are somehow getting file sizes using what looks to be the same method:

http://www.fmforums.com/threads/showflat.php?Cat=0&Number=134712&an=0&page=3#134712

http://www.fmforums.com/threads/showflat.php?Cat=0&Number=133384&an=0&page=4#133384

The files themselves are imported, not just a path to the file. Can anyone tell me what I'm doing wrong?

Thanks,

Kate.

Hi,

I have searched the forums for how to do this, but I couldn't find the answer. Sorry, if it's been posted and I just missed it.

I am making a simple document library, and I want to display the size of files imported into my container field (named 'Image'). I have tried GetAsText(Image), but all it returns is the file name. From other posts, I know that people are somehow getting file sizes using what looks to be the same method:

http://www.fmforums.com/threads/showflat.php?Cat=0&Number=134712&an=0&page=3#134712

http://www.fmforums.com/threads/showflat.php?Cat=0&Number=133384&an=0&page=4#133384

The files themselves are imported, not just a path to the file. Can anyone tell me what I'm doing wrong?

Thanks,

Kate.

  • Author

Hi,

I have searched the forums for how to do this, but I couldn't find the answer. Sorry, if it's been posted and I just missed it.

I am making a simple document library, and I want to display the size of files imported into my container field (named 'Image'). I have tried GetAsText(Image), but all it returns is the file name. From other posts, I know that people are somehow getting file sizes using what looks to be the same method:

http://www.fmforums.com/threads/showflat.php?Cat=0&Number=134712&an=0&page=3#134712

http://www.fmforums.com/threads/showflat.php?Cat=0&Number=133384&an=0&page=4#133384

The files themselves are imported, not just a path to the file. Can anyone tell me what I'm doing wrong?

Thanks,

Kate.

There are two other get functions that may help. Get(FileSize) and Get(ActiveSelectionSize). These may help

There are two other get functions that may help. Get(FileSize) and Get(ActiveSelectionSize). These may help

There are two other get functions that may help. Get(FileSize) and Get(ActiveSelectionSize). These may help

Get(FileSize) returns the current database file's size and Get(ActiveSelectionSize) returns how many characters are selected (highlighted) in the current field. Neither, I'm afraid, will be of any use in this situation.

GetAsText(container) works fine to return the dimensions for imported images on Windows. Maybe it's a Mac issue? Are you using 7.0v3?

Get(FileSize) returns the current database file's size and Get(ActiveSelectionSize) returns how many characters are selected (highlighted) in the current field. Neither, I'm afraid, will be of any use in this situation.

GetAsText(container) works fine to return the dimensions for imported images on Windows. Maybe it's a Mac issue? Are you using 7.0v3?

Get(FileSize) returns the current database file's size and Get(ActiveSelectionSize) returns how many characters are selected (highlighted) in the current field. Neither, I'm afraid, will be of any use in this situation.

GetAsText(container) works fine to return the dimensions for imported images on Windows. Maybe it's a Mac issue? Are you using 7.0v3?

  • Author

Yes, it's 7.0v3. I just started using a Mac last week, so I have no idea how it would make a difference in this particular function. It's not imperative that I have the file size; it would just be a nice feature for my own purposes.

Thanks.

Kate.

  • Author

Yes, it's 7.0v3. I just started using a Mac last week, so I have no idea how it would make a difference in this particular function. It's not imperative that I have the file size; it would just be a nice feature for my own purposes.

Thanks.

Kate.

  • Author

Yes, it's 7.0v3. I just started using a Mac last week, so I have no idea how it would make a difference in this particular function. It's not imperative that I have the file size; it would just be a nice feature for my own purposes.

Thanks.

Kate.

I said: "I don't think you can get the size of an object embedded in a container field."

I am sometimes an idiot. As someone pointed out later (and which I have in one of files but forgot) you can use Length (container field).

This only works with embedded files (or images), not with referenced files (which appears later in this thread).

I said: "I don't think you can get the size of an object embedded in a container field."

I am sometimes an idiot. As someone pointed out later (and which I have in one of files but forgot) you can use Length (container field).

This only works with embedded files (or images), not with referenced files (which appears later in this thread).

I said: "I don't think you can get the size of an object embedded in a container field."

I am sometimes an idiot. As someone pointed out later (and which I have in one of files but forgot) you can use Length (container field).

This only works with embedded files (or images), not with referenced files (which appears later in this thread).

Strangely, on the Mac, GetAsText() gets the file size for a referenced image, but not for one stored within the database. I would have thought the opposite would have been true. With a stored image, all you get is the image's file name which, given that it is stored within the db file, is no longer really a valid attribute of the image...

I have to wonder if this is a planned feature, or just the way it worked out. It would be quite a handy function to be able to find the memory size of a stored image, as a large image can have a devastating effect on a networked solution. Pity that we have to resort to a plug-in for that function.

-Stanley

Strangely, on the Mac, GetAsText() gets the file size for a referenced image, but not for one stored within the database. I would have thought the opposite would have been true. With a stored image, all you get is the image's file name which, given that it is stored within the db file, is no longer really a valid attribute of the image...

I have to wonder if this is a planned feature, or just the way it worked out. It would be quite a handy function to be able to find the memory size of a stored image, as a large image can have a devastating effect on a networked solution. Pity that we have to resort to a plug-in for that function.

-Stanley

Strangely, on the Mac, GetAsText() gets the file size for a referenced image, but not for one stored within the database. I would have thought the opposite would have been true. With a stored image, all you get is the image's file name which, given that it is stored within the db file, is no longer really a valid attribute of the image...

I have to wonder if this is a planned feature, or just the way it worked out. It would be quite a handy function to be able to find the memory size of a stored image, as a large image can have a devastating effect on a networked solution. Pity that we have to resort to a plug-in for that function.

-Stanley

  • Author

It looks like I'm going to not store the files in the database, then, and just upload them to a related folder. Having them stored in the database might be bad design, anyway - it's just my own document library now, but other people will probably end up accessing it and the files are rather large (hi-res PDF).

In your experience(s), *is* it A Bad Thing to store files in the database?

  • Author

It looks like I'm going to not store the files in the database, then, and just upload them to a related folder. Having them stored in the database might be bad design, anyway - it's just my own document library now, but other people will probably end up accessing it and the files are rather large (hi-res PDF).

In your experience(s), *is* it A Bad Thing to store files in the database?

  • Author

It looks like I'm going to not store the files in the database, then, and just upload them to a related folder. Having them stored in the database might be bad design, anyway - it's just my own document library now, but other people will probably end up accessing it and the files are rather large (hi-res PDF).

In your experience(s), *is* it A Bad Thing to store files in the database?

The problem you run into with images stored in the database is that you can suffer real slowdowns on a networked solution; this should be less of a problem in 7 than it was in earlier versions, but it can still slow the system to a crawl, especially if there is a list layout with the images, and a user is able to browse quickly through them...

-Stanley

The problem you run into with images stored in the database is that you can suffer real slowdowns on a networked solution; this should be less of a problem in 7 than it was in earlier versions, but it can still slow the system to a crawl, especially if there is a list layout with the images, and a user is able to browse quickly through them...

-Stanley

The problem you run into with images stored in the database is that you can suffer real slowdowns on a networked solution; this should be less of a problem in 7 than it was in earlier versions, but it can still slow the system to a crawl, especially if there is a list layout with the images, and a user is able to browse quickly through them...

-Stanley

  • 1 month later...

What am I doing wrong?

I'm trying to get the dimensions of images stored in a container field, as discussed here. My images are referenced, not stored directly. I am using the GetAsText (container) function, but it is only giving me the path to the images (image:/G4 DP/Applications/FileMaker Pro 7/Web/WEBSITE-THUMBNAILS/1001T.jpg), and does not give me the dimensions.

This is how it works for me...

If my image is local (on the same computer) the GetAsText () function returns the file size on one line followed by the Path(s) on the following lines. Make sure your field is big enough to display several lines of text.

If my image is on a remote machine the photo size is not calculated.

This works for me when I have manually imported the image (as a referenced file). However, my container fields with the images are actually calculation fields with the result being a container. The GetAsText () function is only giving me the path to the image (which is the path in my calculation).

Is there a way to get the image dimensions in this situation?

Or maybe there is another way to do what I'm trying to accomplish. What I'm trying to do is have my database automatically determine if an image is a vertical, horizontal, (portrait or landscape), or square. Is there another way of doing this?

If you have the path (converted to a Mac AppleScript path, with ":") and you're on Mac OS X, could you use ImageEvents to get the dimensions? Example:

set theImage to choose file

-- returns an alias path; you'd need the mounted volume name at the first

tell application "Image Events"

launch

set thisImage to open theImage

try

set theSize to dimensions of thisImage

set theHeight to (item 2 of theSize)

set theWidth to (item 1 of theSize)

end try

end tell

Thanks for your help. Here is my exact calculation path (IMAGE NUMBER is a field in each record):

"image:/G4 DP/Applications/FileMaker Pro 7/Web/WEBSITE-DISPLAY_IMAGES/" & IMAGE NUMBER & ".jpg"

I don't know what ImageEvents is or how it works (and I did a search for it and couldn't find anything). Can you give me some more info on this approach? Thanks.

Image Events (not ImageEvents, my typo) is a built-in faceless application in OS X, at least in Panther and above. It will be more well known in Tiger. It can handle simple image processing and conversion. To see what it can do, open it with Script Editor, or drop it on Script Editor (or put it in Script Editor's Library drawer, most convenient). This is where it is:

Macintosh HD:System:Library:CoreServices:Image Events.app

All you need to do is get your path into standard AppleScript Mac file path syntax, by using a FileMaker text calculation. Like:

_cImagePath =

"G4 DP:Applications:FileMaker Pro 7:Web:WEBSITE-DISPLAY_IMAGES:" & IMAGE NUMBER & ".jpg"

Calc result.

"G4 DP:Applications:FileMaker Pro 7:Web:WEBSITE-DISPLAY_IMAGES:12142.jpg"

Pass that to AppleScript. Add a "alias " or "file " prefix for a file reference. Then ImageEvents can get the dimensions.

Ex. (_cImagePath is on the current layout):

--tell app "FileMaker Pro"

-- not needed in a Perform AppleScript step, only in Script Editor

set theImage to cell "_cImagePath" of current record

tell application "Image Events"

launch

set thisImage to open file theImage

try

set theSize to dimensions of thisImage

set theHeight to (item 2 of theSize)

set theWidth to (item 1 of theSize)

end try

close thisImage

end tell

set cell "ImageWidth" of current record to theWidth

set cell "ImageHeight" of current record to theHeight

-- end tell

-- not needed in a Perform AppleScript step, only in Script Editor

Thanks for all the info. I'm going out of town for a week, but I'll check it out when I get back.

  • 2 weeks later...

I just make a Formula Field and define it as...

length(the name of your container field)

It works for me but I am not sure if thats what you want. You can always round that up(or down). It displays your file size in Byte, so you might want to divide by 1000 or a million. Try it?

I'm not trying to get the file size. I'm trying to get the dimensions of the images, in pixels or inches.

Any other suggestions? What I really want is for my database to automatically determine if an images is vertical, horizontal, or square. I just figured this was the first step, but maybe there is another way.

thats right, I am sorry, I should have read the post more carefully. I like Fenton method, does it work for you?

I still haven't had a chance to try it yet.

Create an account or sign in to comment

Important Information

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

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.