How to Generate and Save Images On-demand in Airtable

Streamline asset creation by generating and saving images directly in Airtable. In this article, learn how to set up this simple, on-demand workflow with Bannerbear and Airtable's Scripting extension.
by Julianne Youngberg ·

Contents

    In today's fast-paced digital environment, the ability to create images quickly and precisely has become a critical skill for businesses and creators alike. Digital tools are evolving, and the gap between technical capability and creative expression is narrowing in response. The most effective approach often combines technological efficiency with human creativity, particularly for on-demand use cases that require greater control.

    While full automation works well for predictable design tasks, this article explores a flexible method that combines Bannerbear’s capabilities with Airtable. We'll show you how to enable the Scripting extension, which allows you to generate and save images directly in your database with a single button click.

    Why Generate Images On-Demand?

    PNG (Portable Network Graphics) and JPG (Joint Photographic Experts Group) are versatile, widely supported file formats that compress graphic details down to make them easy to store and use. Since they’re compact, they’re ideal for many automation use cases where storage is less of an issue.

    Even so, there are situations where on-demand image generation is preferred, such as when:

    • Human judgment of context is helpful
    • Data or design needs to be very precise
    • Graphics are used as they are created
    • Data is sporadically changing

    Creating images as needed allows you to maintain greater control over graphic production and adjust your approach as you go.

    What You Will Create

    Generating images with a button within your Airtable base allows you to control image creation while enjoying the efficiency of automatic generation and storage.

    The tools you will need to set up the workflow are:

    • Airtable : To store data and attached files
    • Bannerbear : To design templates and generate images

    Bear Tip 🐻: You will need a paid Airtable plan to access Extensions.

    By the end of the tutorial, you should have an Airtable base with buttons that can be clicked to generate and store images.

    Screenshot of Airtable base with certificate generation and output outlined in red Screenshot of generated Bannerbear image in Airtable attachment field

    Let’s get started!

    How to Set Up a Button to Generate Images in Airtable

    The Scripting extension enables you to generate Bannerbear images directly within Airtable, eliminating the need to switch between apps. With a single button click, you can instantly create an image that’s stored and ready to use.

    We'll configure your Airtable base, then use the Scripting extension to integrate Bannerbear and create a streamlined button-triggered workflow.

    Step 1. Prepare Your Airtable Base

    First, you’ll need an Airtable base with data that you want to include in your generated images. This might be text, links, or even emojis!

    Screenshot of Airtable base with sample data

    Bear Tip 🐻: Images can be dynamically inserted into your templates too! Use direct links as modifications in your API call.

    You’ll need an attachment type field in your table to store created images.

    Screenshot of Airtable base with red arrow pointing to output attachment field

    Add multiple fields if you’ll be generating multiple images, or storing multiple formats.

    Step 2. Add a Scripting Extension

    Extensions add more functionality to your Airtable base and allow you take advantage of other apps’ features. Scripting is an Airtable-built extension that allows you to write custom JavaScript code, giving your base features beyond the basics. With it, you can build in features like advanced data manipulation and custom report generation.

    To add a new extension to your base, you’ll need a paid Airtable plan.

    Click the Extensions tab on the right side of your table. This will reveal a dashboard where you can add new extensions, enable and disable them, and assign them to different dashboards.

    Screenshot of Airtable base with red arrow pointing to Extensions tab

    Click Add an extension.

    Screenshot of Airtable extensions tab with Add an extension outlined in red

    Conduct a search for the Scripting extension, then click Add.

    Screenshot of Airtable extensions marketplace with red arrow pointing to Add scripting extension

    Once the extension loads onto your base, you should be on a page where you can edit and test scripts.

    Screenshot of Airtable Scripting extension editor

    Click Get started , and start editing from scratch.

    Step 3. Customize Your Code

    The script added to the base will send a request for image generation containing your modifications to Bannerbear, then fetch the results to upload them to the attachment field.

    Insert the following code into the editor:

    const API_KEY = '{YOUR_API_KEY}'
    let table = base.getTable("{YOUR_TABLE_NAME}")
    let record = await input.recordAsync('Pick a record', table)
    
    var data = {
      "template": '{YOUR_TEMPLATE_UID}',
      "modifications": [
        {
          "name": "image_container",
          "image_url": record.getCellValue('Photo')
        },
        {
          "name": "title",
          "text": "Certificate of Adoption",
          "color": null,
          "background": null
        },
        {
          "name": "pretitle",
          "text": "This hereby certifies that",
          "color": null,
          "background": null
        },
        {
          "name": "adoptee_name",
          "text": record.getCellValue('Name'),
          "color": null,
          "background": null
        },
        {
          "name": "paragraph",
          "text": "has been adopted by *" + record.getCellValue('Adopted By') + "* into a lifetime of happiness and cuddles.",
          "color": null,
          "background": null
        },
        {
          "name": "date_title",
          "text": "Adoption Date",
          "color": null,
          "background": null
        },
        {
          "name": "date",
          "text": record.getCellValue('Adoption Date'),
          "color": null,
          "background": null
        },
        {
          "name": "logo_text",
          "text": "Whiskers & Wags",
          "color": null,
          "background": null
        }
      ],
    }
    
    let response = await fetch('https://sync.api.bannerbear.com/v2/images', {
      method: 'POST',
      body: JSON.stringify(data),
      headers: {
        'Content-Type' : 'application/json',
        'Authorization' : `Bearer ${API_KEY}`
      }
    })
    
    let respJSON = await response.json()
    
    console.log (respJSON)
    
    await table.updateRecordAsync(record.id, {
      "{YOUR_OUTPUT_FIELD}": [{url:respJSON.pdf_url}],
    });
    

    Change the following placeholder text with your own details:

    • YOUR_API_KEY - Found on the project’s Settings / API Key page
    • YOUR_TABLE_NAME - According to your Airtable project
    • YOUR_TEMPLATE_UID - Found by clicking the meatball menu on your template page
    • YOUR_OUTPUT_FIELD - According to your Airtable project

    You will also have to replace the modifications section to align with your template. One easy way to do this is to return to your Bannerbear app and go to your template page. Scroll down to the API Console , then copy and paste the entire modifications section into your script.

    Screenshot of Bannerbear API console with modifications section outlined in red

    You can then modify each layer with replacement text, background colors, links, fonts, and whatever you need.

    If you need help modifying the request, refer to Bannerbear’s API reference.

    Bear Tip 🐻: Use record.getCellValue('{FIELD_NAME}') to refer different fields and dynamically update them per record.

    Testing the script should reveal the output log of a successful image generation run.

    Screenshot of Airtable Scripting extension editor with console log outlined in red

    You should see output links to your newly created images.

    Step 4. Create a Button

    If your script is working correctly, all that’s left to do is to link it to a button that launches it when clicked. From your Airtable base, add a new button field.

    Screenshot of Airtable base with red arrow pointing to new button field

    Customize the name, label, and style according to your preferences. Choose Run script as the action, and select the dashboard and extension you were previously working on.

    Screenshot of Airtable base with new button field type setup outlined in red

    Click Create field when done.

    Step 4. Test the Process

    The final step is to test and make sure your button is generating images according to your needs. Make sure you have a record of sample data, then click Generate.

    Screenshot of Airtable base with create certificate button outlined in red

    The extensions tab should open up to run your script, then upload the image into your output field.

    Screenshot of Airtable base with red arrow pointing to output image

    You can click on the attachment to view the completed photo.

    Screenshot of generated Bannerbear image in Airtable attachment field

    Conclusion

    Generating images on an as-needed basis suits many use cases where data is constantly changing and storage is limited. But rather than customizing each image, saving it, and uploading to your database, you can use a script that does all of that behind the scenes for you.

    Bannerbear’s image generation capabilities can be integrated into your Airtable base, eliminating the need to switch between apps and streamlining your workflow.

    For more Airtable image generation ideas, check out a few of our other articles:

    👉 How to Generate and Save PDFs On-demand in Airtable

    👉 How to Generate Bannerbear Images with Airtable (Integration Guide)

    👉 How to Instantly Generate Certificates Online with Bannerbear and Airtable

    About the authorJulianne Youngberg@paradoxicaljul
    Julianne is a technical content specialist fascinated with digital tools and how they can optimize our lives. She enjoys bridging product-user gaps using the power of words.

    How to Generate Dynamic Images with Bannerbear in PHP: A Beginner's Guide

    Learn how to automate branded image creation using Bannerbear's PHP library. This step-by-step guide covers everything you need to know to dynamically generate images from different data, making the process of image creation more efficient.

    How to Generate and Save PDFs On-demand in Airtable

    Learn how to generate and save PDFs directly in Airtable using the built-in Scripting extension and Bannerbear, streamlining document creation with a simple, on-demand workflow.

    How to Save Generated Bannerbear PDFs to Airtable with Zapier

    When you're generating PDFs in bulk, manual storage can be costly and inefficient. Fortunately, you can store as you go by automatically saving links to Airtable. Read this article to learn how to automate this process without code.

    Automate & Scale
    Your Marketing

    Bannerbear helps you auto-generate social media visuals, banners and more with our API and nocode integrations

    How to Generate and Save Images On-demand in Airtable
    How to Generate and Save Images On-demand in Airtable