Read width/height of an attachment

Topic Labels: Scripting extentions
3353 9
Showing results for 
Search instead for 
Did you mean: 
6 - Interface Innovator
6 - Interface Innovator

I’m trying to read what are the width/height of a given image. The following JS code works fine outside Airtable:

const img = new Image();
img.onload = function() {
  alert(this.width + 'x' + this.height);
img.src = '';

But when writing an Airtable script, const img = new Image(); yields ReferenceError: Image is not defined.

Is there another way to know what are the width/height of an image within an Airtable script?

9 Replies 9
5 - Automation Enthusiast
5 - Automation Enthusiast

Hey @TFP !

Could you solve this problem? I am trying to achieve the same thing :slightly_smiling_face:


8 - Airtable Astronomer
8 - Airtable Astronomer

@JJ_Velaz Yes, I did. But not using Airtable, I had to write an automation which calls my own API and used some Node.js code to resolve the width/height. Didn’t find any viable solution with Airtable alone.

If you use cURL, the Airtable API will return the width/height of attachments.

6 - Interface Innovator
6 - Interface Innovator

With Airtable automations I see height and width in the results when doing a test run, but I’m not able to select them as variables to auto fill a field.
Thoughts / solutions anyone?

I never noticed that before, but you are correct that Airtable’s Automations don’t give you full access to all the attachment details that the REST API returns.

However, gives you full access to all the width & height information for your attachments. Not just for the full-sized attachment, but also for all of the thumbnails that Airtable generates as well.

(I haven’t tested this with Zapier, but I’m assuming that Zapier will do the same thing.)

Please see attached screenshot below for all the information that you can pull from an attachment in

Screen Shot 2022-04-06 at 9.14.06 AM

4 - Data Explorer
4 - Data Explorer

Would there be a way to pull into a field - the image width/height info from a file that resides in Google Drive (in a Table with the Sync feature)?

Yes, absolutely! You can do this in a variety of ways (i.e. scripting or are 2 ways of doing this), but the way that I personally do it is with This is the easiest way in my opinion, because it doesn’t require any code nor any knowledge of APIs.

Thanks. Yes, I am playing with and it seems to work. The issue I am seeing is that the width and height that it is pulling is from the Thumbnail preview that is presented on the table (generated by Airtable), rather than the actual dimensions of the file hosted on Google Drive. Would you happen to know how to query the dimensions of the image file on Google Drive, which is being Sync to Airtable?

If you want to pull from Google Drive, just setup the google Drive modules to pull from the Google Drive File ID. However, you probably won’t need to do that, because Airtable stores the width & height data for all 3 thumbnail sizes: small, large, and full. Just choose full:

Screen Shot 2022-06-10 at 6.29.54 PM