og:image width, height and alt tags for an AI image from Sume

Open Graph has optional og:image:width, og:image:height and og:image:alt. Read the real size from a Sume render with Pillow and print all three tags.

5 min readSume
All posts

The Open Graph protocol (read 2026-10-03) requires four properties, og:title, og:type, og:image and og:url, and lists optional image properties including og:image:width and og:image:height (pixels wide and high), og:image:alt (a description of what is in the image, not a caption), og:image:type and og:image:secure_url. For an image made on Sume, open the downloaded file with Pillow, read its true size and print the tags.

What the protocol says

The definitions below are from ogp.me.

Open Graph image properties (read 2026-10-03)
PropertyMeaning on ogp.me
og:imageAn image URL which should represent your object within the graph
og:image:widthThe number of pixels wide
og:image:heightThe number of pixels high
og:image:altA description of what is in the image (not a caption)
og:image:typeA MIME type for this image
og:image:secure_urlAn alternate url to use if the webpage requires HTTPS

Why read the size from the file

A Sume model returns the pixels it chose for the ratio you asked for, so do not guess. Ask for 16:9, download, and measure. Use your own host for the final URL: the image URL in data[].url is a Sume URL and the tag should point to a copy you publish.

Script

It generates one image, saves it, and prints the tags with the measured size. Replace the host and alt text.

import os, requests
from io import BytesIO
from PIL import Image

r = requests.post("https://api.sume.com/v1/images", timeout=120,
    headers={"Authorization": f"Bearer {os.environ['SUME_API_KEY']}"},
    json={"model": "black-forest-labs/flux.2-pro", "aspect_ratio": "16:9",
          "output_format": "jpeg", "prompt": "minimal illustration of a paper plane over a city, empty left third"})
if r.status_code != 200:
    raise SystemExit(f"{r.status_code}: {r.text[:200]}")
raw = requests.get(r.json()["data"][0]["url"], timeout=60).content
open("card.jpg", "wb").write(raw)
w, h = Image.open(BytesIO(raw)).size
base = "https://example.com/img/card.jpg"
print(f'<meta property="og:image" content="{base}">')
print(f'<meta property="og:image:width" content="{w}">')
print(f'<meta property="og:image:height" content="{h}">')
print('<meta property="og:image:type" content="image/jpeg">')
print('<meta property="og:image:alt" content="A paper plane flying over a city skyline">')

Alt text is a description

ogp.me says the alt is a description of what is in the image, not a caption. Write what a person would see: subject, setting, and any visible words. Because Sume generated the picture from your prompt, the prompt is a starting point, but check it against the actual file.

What Sume does not do

Sume does not write your page's meta tags or host them for you. The cost of the image above is the Flux 2 Pro price of $0.0375.

Sources

Related posts

More in Developers

All Developers posts

Written by Sume