Skip to content

Background Images

Background image compositing lets you generate cards that combine a photograph or artwork with your text. OG Engine handles resizing, cropping, and darkening the image so your text always remains legible.

When you supply a background image, OG Engine:

  1. Decodes the image (JPEG, PNG, or WebP)
  2. Resizes and center-crops it to exactly fill the canvas dimensions for your chosen format
  3. Applies a dark overlay at the specified overlayOpacity to ensure text contrast
  4. Renders text on top using the template’s layout rules

The result is a single flat PNG (or WebP) with your image, overlay, and text composited together.

Background image upload uses multipart/form-data. The JSON payload goes in a field named config, and the image file goes in a field named image:

Terminal window
curl -X POST https://og-engine.com/render \
-H "Authorization: Bearer oge_sk_YOUR_KEY" \
-F 'config={
"format": "og",
"template": "blog-hero",
"title": "Why Server-Side Rendering Still Matters",
"description": "A deep dive into modern SSR patterns.",
"tag": "Architecture",
"style": { "overlayOpacity": 0.6 }
}' \
-F 'image=@/path/to/cover.jpg' \
--output card.png

Note that when uploading an image, Content-Type is set automatically by curl. Do not manually set it to application/json.

import { OGEngine } from '@atypical-consulting/og-engine-sdk'
import { readFile } from 'fs/promises'
const og = new OGEngine(process.env.OG_ENGINE_KEY!)
const coverImage = await readFile('./public/cover.jpg')
const imageBuffer = await og.render({
format: 'og',
template: 'blog-hero',
title: 'Why Server-Side Rendering Still Matters',
description: 'A deep dive into modern SSR patterns.',
tag: 'Architecture',
style: { overlayOpacity: 0.6 },
backgroundImage: coverImage,
})

The style.overlayOpacity field controls how dark the overlay applied to your background image is:

ValueEffect
0.2Very light overlay — image is prominent, text may be hard to read on light images
0.4Light overlay — good for very dark source images
0.65Default — balanced for most photographs
0.8Heavy overlay — maximizes text legibility
0.9Near-opaque — image visible only as a subtle texture

Range: 0.2 – 0.9 Default: 0.65

{ "style": { "overlayOpacity": 0.7 } }

For bright, colorful images like travel photography, use 0.70.8. For dark editorial images, 0.40.55 often preserves more of the image while keeping text readable.

FormatExtensionsNotes
JPEG.jpg, .jpegMost common; smallest file size
PNG.pngSupports transparency (composited on black)
WebP.webpModern format; good quality-to-size ratio

Maximum file size: 5MB

Images larger than 5MB are rejected with an invalid_file error. For high-resolution source images, consider resizing to ~2400×1260 (2x the OG canvas) before sending — this provides sufficient quality without the file size overhead.

The blog-hero template is specifically designed for background image use. It:

  • Anchors text to the lower-left quadrant, leaving the upper portion for the image to breathe
  • Renders the tag pill above the title
  • Includes the author line at the very bottom
  • Reduces the grid pattern opacity to avoid fighting with the background image detail

You can use background images with any template, but blog-hero produces the most polished results.

{
"format": "og",
"template": "blog-hero",
"title": "The Hidden Cost of Microservices",
"description": "When monoliths are actually the right answer.",
"author": "Jane Smith",
"tag": "Engineering"
}

If template is set to blog-hero but no image is uploaded, the template falls back to the selected style.gradient as the background. All other layout rules still apply.

The playground preview below uses a solid gradient background (file upload is not available client-side). To see background image compositing, use the curl or SDK examples above with a local image file:

0.0ms|8500x