Skip to Content
FeaturesModulesOG ImagesLayouts

OG Image Layouts

Layout presets control the visual structure of a rendered image: where the accent bar appears, where the brand overlay (logo + site name) is placed, and how content text is aligned.

Built-in presets

PresetAccentBrandContent alignTitle font
DEFAULTtopbottom-leftcenter68
HEROtoptop-leftbottom80
ARTICLEnonetop-leftcenter60
MINIMALnonenonecenter72

DEFAULT

Standard OG image — accent bar at the top, brand in the bottom-left corner, content centered vertically.

from django_cfg.modules.django_ogimage import DEFAULT, render, OGImageParams png = render(OGImageParams(title="Hello"), layout=DEFAULT)

HERO

Large title, content pushed to the bottom, brand in the top-left — good for landing page screenshots or product images.

from django_cfg.modules.django_ogimage import HERO, get_branded_og_url, DARK_BLUE url = get_branded_og_url( DARK_BLUE.to_params(title="Product Launch"), site_name="Acme", layout=HERO, )

ARTICLE

No accent bar, smaller title font, brand in the top-left — editorial look for blog posts and documentation pages.

from django_cfg.modules.django_ogimage import ARTICLE url = get_branded_og_url( DARK_BLUE.to_params(title="How to Deploy Django", description="Step-by-step guide"), site_name="Acme Docs", layout=ARTICLE, )

MINIMAL

No accent, no brand overlay — content only, centered. Maximum whitespace.

from django_cfg.modules.django_ogimage import MINIMAL png = render(OGImageParams(title="Just the title"), layout=MINIMAL)

Registry

from django_cfg.modules.django_ogimage import ALL, get_layout # All presets as dict # {"default": DEFAULT, "hero": HERO, "article": ARTICLE, "minimal": MINIMAL} layout = get_layout("hero") # returns HERO layout = get_layout("nonexistent") # raises ValueError

OGLayoutPreset fields

FieldTypeDefault (DEFAULT)Description
namestr"default"Registry key
accent_position"top" | "bottom" | "none""top"Accent bar placement
brand_position"top-left" | "top-right" | "bottom-left" | "bottom-right" | "none""bottom-left"Brand overlay corner
content_align"center" | "start" | "end""center"Vertical alignment of title/description block
padding_xint60Horizontal padding in pixels
padding_yint60Vertical padding in pixels
logo_sizeint40Logo/icon height in pixels
site_name_font_sizeint26Site name label font size
title_font_sizeint68Title font size
description_font_sizeint30Description font size

Presets are frozen — mutation raises an exception. They are also hashable and safe to use as dict keys or in sets.

corner_to_fixed_pos

Low-level helper used internally by the renderer to translate a brand_position corner name into pixel coordinates:

from django_cfg.modules.django_ogimage import corner_to_fixed_pos pos = corner_to_fixed_pos("bottom-left", px=60, py=60) # → {"bottom": 68, "left": 60}
Last updated on