PICTIFY
Building a Quote Image Generator for Instagram
Programming

Building a Quote Image Generator for Instagram

Pictify Engineering
8 Aug
6 min read

Introduction

In this tutorial, we'll walk you through creating a quote image generator for Instagram using Node.js and the Pictify API. This tool will allow you to automatically generate visually appealing quote images, perfect for engaging your Instagram audience and maintaining a consistent aesthetic on your profile.

Why build a quote image generator?

  1. Engagement: Quote posts often receive high engagement on Instagram.
  2. Consistency: Maintain a cohesive visual style across your quote posts.
  3. Time-saving: Automate the process of creating quote images.
  4. Customization: Easily adapt quotes to fit your brand's style.

Prerequisites

Before we begin, ensure you have:

  1. Node.js installed on your machine
  2. A Pictify API key (sign up at pictify.io)
  3. A unsplash API key (sign up at unsplash.com)
  4. Basic knowledge of JavaScript and Node.js

Step 1: Project Setup

Create a new directory for your project and initialize it:

bash

Install the required packages:

bash

Create a new file quoteGenerator.js and add the following boilerplate:

javascript

Step 2: Create the Image Template

Create a new file quoteTemplate.ejs with the following content:

html

Step 3: Generate Quote Content

Add a function to fetch a random quote. For this example, we'll use the Quotable API:

javascript

Step 4: Generate the Quote Image

Add a function to generate the quote image using Pictify API:

javascript

Step 5: Put It All Together

Add a main function to run the quote image generator:

javascript

Running the Generator

To run the quote image generator, execute:

bash

Example output:

bash

Example Quote Image

This will output a URL to your generated quote image, which you can then download or use in your Instagram posts.

Step 6: Adding Multiple Visual Themes

A single static design gets stale fast if you're posting daily. Instead of one quoteTemplate.ejs, maintain a small set of templates and pick one per quote so your feed doesn't look like the same card recolored.

Create three more templates alongside the original:

  • quoteTemplateMinimal.ejs: plain background color, no photo, large centered type
  • quoteTemplateBold.ejs: solid brand color background, oversized quote text, no author photo overlay
  • quoteTemplateGradient.ejs: CSS gradient background instead of an Unsplash photo, useful when you want zero external image dependency

Each one takes the same quoteText / quoteAuthor variables as the original; only the CSS and background source change. A gradient variant, for example, drops the backgroundImage param entirely:

html

Now map template names to files and pick one, either at random or on a rule (e.g. rotate by day of week so Mondays always look the same way):

javascript

This replaces the generateQuoteImage function from Step 4: same signature, but now template-aware. Everything downstream (Step 5's main()) keeps working unchanged, since templateName defaults to a random pick when you don't pass one.

Step 7: Batch-Generating a Week's Worth of Quotes

Once you're managing a content calendar rather than posting one-off, generating images one at a time in a loop each morning gets tedious. Generate a week's batch in a single run instead.

javascript

This runs sequentially with await inside the loop rather than firing all seven requests via Promise.all; both the Quotable API and Unsplash's free tier rate-limit aggressively, and a sequential loop is easier to reason about when one request in the middle fails. If you're generating from your own quote list instead of a random API, Promise.all over a fixed array is safe and considerably faster:

javascript

The output JSON (quote-batch.json) is the handoff point to whatever you use for scheduling: each entry has a ready-to-use image URL plus the quote metadata, indexed by day.

Step 8: Auto-Posting to Instagram

Generating the images is half the job; the other half is getting them onto your feed without opening Instagram seven times a week. Three practical options, roughly in order of setup effort:

Scheduling tools (Buffer, Later). Both accept an image URL via their API and let you queue a post for a specific time. Since generateBatch() above already returns a plain image URL per quote, wiring it into Buffer's API is a short loop:

javascript

Meta's Graph API directly. More setup (a Meta developer app, an Instagram Business account, a long-lived access token) but no third-party dependency. The flow is a two-step publish: create a media container from the image URL, then publish that container.

A cron job that just calls generateBatch() and stops there. If you'd rather review images before they go live, the simplest reliable pattern is: cron generates the week's batch into quote-batch.json every Sunday night, you glance at it Monday morning, and post manually. Automation doesn't have to mean zero human review; for a brand account, it often shouldn't.

Conclusion

You've now created a powerful tool for generating Instagram quote images using Node.js and the Pictify API, one that supports multiple visual themes, can batch-generate a week of content in one run, and has a clear path to scheduled auto-posting. This generator can be further customized to fit your brand's style by adjusting the EJS templates, using specific fonts, or integrating with your own quote database.

To extend this project further, consider:

  • Pulling quotes from your own curated database instead of the random Quotable API, so every quote is on-brand
  • Adding a review step (Slack notification, simple web UI) between batch generation and scheduling
  • A/B testing which template style gets the most engagement, then weighting pickTemplate() toward the winner

Happy quote posting!

Free Tier Available

Run Your First Batch In Under 5 Minutes

Sign up, pick a template, add your data. Get pixel-perfect documents rendered and delivered in minutes.

Read Docs
4:59
Time to first batch
API Ready
50 Free Credits

Instant Access

Get your API key immediately upon signup. Start integrating in seconds.

50 Free Credits

No credit card required. Test the API for free and see the pixel-perfect results.

Secure Infra

Enterprise-ready security and isolation. Your data is processed safely.