Automated replacement of images in existing table records

Dear Airtable community,

I have the following use case: inside my Airtable DB I have an image table holding about 9000 records whereas each record has an attachment field (among other fields) holding a single image of a certain resolution. I would now like to (1) download all these images, (2) do some optimizations on them (using e.g. imagemagick) and (3) re-upload the processed images replacing the previous ones. Steps (1) and (2) I’m confident to figure out myself how to do that. For step (3) however I’m a bit lost. Do you have any suggestions about how to best realize that in a (semi-) automated way? Any scripting fragments or similar would be a great help.

Thanks, Stefan

Step 3 is the kicker. The way I’d approach it (just from thinking about it briefly) is either:

  1. Carry out steps 1 & 2. ensuring that the image name is the same and unique across all records, use the API to lookup based on the image name, and replace with new image

  2. Depending on what you need to do with Image Magick you could maybe do the same thing with an image automation platform (e.g Transloadit)

Thanks for your reply @andywingrave. Do you happen to have a code snippet showing how to upload an image file to a specific record field replacing the previous one?

Thanks, Stefan

I don’t at the moment, sadly :pensive:

Perhaps ask in the Work Offered category for now?

Thanks @andywingrave. I think I have found a way to solve that. Using Airtable Scripts Block, the following code snippet can update a record with an image, provided the image can be read from a remote server:

let newAttachmentUrl = '';
await table.updateRecordAsync(record, {
    "ImageField": [
     { url: newAttachmentUrl,
       filename: 'mynewimage.jpg' }

Regards, Stefan

1 Like

Awesome! Nice one! Thank you for posting the solution!