Help

Automated replacement of images in existing table records

Topic Labels: ImportingExporting
2785 5
cancel
Showing results for 
Search instead for 
Did you mean: 
Stefan_Kunz
6 - Interface Innovator
6 - Interface Innovator

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

5 Replies 5

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)

Stefan_Kunz
6 - Interface Innovator
6 - Interface Innovator

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 = 'https://www.domain.com/mynewimage.jpg';
await table.updateRecordAsync(record, {
    "ImageField": [
     { url: newAttachmentUrl,
       filename: 'mynewimage.jpg' }
    ],
})

Regards, Stefan

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