Free tools Windows power users keep installed
One-click scans. No signup required.
Use Pillow to draw a page title onto an image canvas, save the image, publish it at a public URL, and point the page’s og:image metadata to that URL. The example below creates a 1200 × 630 PNG; choose dimensions for your target publishing context, since the Open Graph Protocol does not set one universal image size.
Install Pillow and choose a font
Install Pillow in the Python environment that will generate the image:
python -m pip install Pillow
Use a real font file so the design does not depend on whichever fonts happen to be installed on a developer’s machine. Bundle a licensed font with your application or configure a font path that exists in the production environment. Pillow’s ImageFont reference documents loading TrueType fonts with ImageFont.truetype.
Generate a title image with Python
This runnable script wraps the title to fit a fixed-width text area, centers the text, and saves a PNG. Replace FONT_PATH with the path to a bundled TrueType font. The text uses a maximum font size and steps down until it fits the available height.
Quick wins for a faster PC:
Scan for outdated or missing drivers - takes under a minuteDriver Scan →Clear out junk files and repair common Windows errorsFree Scan →Fix the driver behind crashes, sound loss and screen glitchesFind Drivers →#1 Best Overall
- Read Before You Buy — No Video Output: These adapters support charging and USB 2.0 data transfer, but cannot transmit video signals. Except for standard USB webcams (which use USB data only), they are not compatible with HDMI/DisplayPort cables, video-capable USB-C hubs, or docking stations with video output.
- Convert USB-A Ports to USB-C: Designed to connect USB-C earphones, cables, flash drives, card readers, and other USB-C accessories to standard USB-A ports. Plug-and-play with no drivers or software required.
- Aluminum Alloy Housing: Built with a sturdy aluminum alloy shell that aids in heat dissipation and protects against daily wear and scratches. Designed to maintain a stable and secure connection.
- Compact & Travel-Friendly: The ultra-compact design allows the adapter to stay plugged into your device without blocking adjacent ports or adding bulk, reducing wear and tear on your original USB ports.
- 12-Month Warranty: Backed by a 12-month manufacturer warranty for peace of mind. Designed to meet strict quality control standards for reliable everyday performance.
from pathlib import Path
from PIL import Image, ImageDraw, ImageFont
TITLE = "How to Create an Open Graph Image with Python"
OUTPUT = Path("og-image.png")
FONT_PATH = Path("fonts/DejaVuSans-Bold.ttf")
WIDTH, HEIGHT = 1200, 630
PADDING_X = 100
PADDING_Y = 72
MAX_FONT_SIZE = 76
MIN_FONT_SIZE = 40
LINE_SPACING = 14
BACKGROUND = "#172554"
FOREGROUND = "#ffffff"
def wrap_text(text, draw, font, max_width):
"""Wrap text at spaces so each rendered line fits max_width."""
words = text.split()
lines = []
current = ""
for word in words:
candidate = word if not current else f"{current} {word}"
if draw.textlength(candidate, font=font) <= max_width:
current = candidate
else:
if current:
lines.append(current)
# Keep a single unusually long word rather than dropping it.
current = word
if current:
lines.append(current)
return lines
image = Image.new("RGB", (WIDTH, HEIGHT), BACKGROUND)
draw = ImageDraw.Draw(image)
max_text_width = WIDTH - 2 * PADDING_X
max_text_height = HEIGHT - 2 * PADDING_Y
for font_size in range(MAX_FONT_SIZE, MIN_FONT_SIZE - 1, -2):
font = ImageFont.truetype(str(FONT_PATH), font_size)
lines = wrap_text(TITLE, draw, font, max_text_width)
boxes = [draw.textbbox((0, 0), line, font=font) for line in lines]
line_heights = [bottom - top for left, top, right, bottom in boxes]
total_height = sum(line_heights) + LINE_SPACING * (len(lines) - 1)
if total_height <= max_text_height:
break
else:
raise ValueError("Title does not fit; shorten it or increase the available text area.")
# Center the block vertically, then center each line horizontally.
y = (HEIGHT - total_height) / 2
for line, box, line_height in zip(lines, boxes, line_heights):
left, top, right, bottom = box
line_width = draw.textlength(line, font=font)
x = (WIDTH - line_width) / 2
# Offset by the bounding-box origin so glyph overhangs remain centered.
draw.text((x - left, y - top), line, font=font, fill=FOREGROUND)
y += line_height + LINE_SPACING
image.save(OUTPUT, format="PNG")
print(f"Wrote {OUTPUT.resolve()}")
The example uses textlength to wrap lines and textbbox to estimate their vertical bounds. Pillow notes that advance length and bounding-box extent are not interchangeable for every font: italics, accents, and other glyph shapes can extend beyond the measured advance. Kerning can also make the measured length of a combined string differ from the sum of its parts. Inspect the actual rendered image with the font and titles you intend to publish. See Pillow’s ImageDraw reference for text drawing and measurement details.
Choose dimensions and format for the destination
Set WIDTH and HEIGHT to match the publishing context you care about. Open Graph defines the image metadata role but does not establish a universal pixel size. A target social platform may publish its own current image guidance, so check that platform’s requirements rather than treating a common size as an Open Graph rule.
Rank #2
- 5-in-1 USB-C Hub: Experience comprehensive connectivity featuring a Power Delivery input, two USB-A 2.0 ports, a USB-A 3.0 port, and an HDMI port. (Note: The USB-C power delivery input port is only for connecting an external wall charger to power your laptop and cannot power peripheral devices.)
- 90W Pass-Through Charging: Achieve optimal charging with 90W pass-through power to your laptop, supported by a total input of 100W, with the hub reserving 10W for operational efficiency. (Note: Wall charger not included.)
- Quick Data Transfers: Accelerate your productivity with rapid data transfers using a high-speed 5Gbps USB 3.0 port and two 480Mbps USB 2.0 ports.
- 4K HDMI Display: Enhance your visual experience with a hub capable of delivering 4K resolution at 30Hz in both mirror and extend modes. Please note that this hub is compatible with MacBook (macOS 12 and newer), Windows 10 and 11, ChromeOS, and laptops equipped with DP Alt Mode and Power Delivery. Note: This device is not compatible with Linux.
- What You Get: Anker USB-C Hub (5-in-1, 4K HDMI), welcome guide, 18-month warranty, and our friendly customer service.
The script writes PNG explicitly. To save JPEG instead, create an RGB image as this example does and use image.save("og-image.jpg", format="JPEG", quality=90). Pillow can infer a format from a path extension; when saving to a file object, pass the format explicitly. Consult Pillow’s Image reference for saving behavior.
Publish the image and add Open Graph metadata
Upload the generated file somewhere that can serve it at a stable, publicly reachable URL, then use that URL in the page’s HTML head. Open Graph metadata points to the image by URL; it does not embed the image bytes in the page. The protocol’s basic properties include og:title, og:type, og:image, and og:url. When an image is specified, include og:image:alt describing it. The image MIME type and dimensions can also be supplied as structured properties.
Do these 3 things before closing this tab:
1Fix the driver behind crashes, sound loss and screen glitches2Clear out junk files and repair common Windows errors3Scan for outdated or missing drivers - takes under a minuteRank #3
- Sleek 7-in-1 USB-C Hub: Features an HDMI port, two USB-A 3.0 ports, and a USB-C data port, each providing 5Gbps transfer speeds. It also includes a USB-C PD input port for charging up to 100W and dual SD and TF card slots, all in a compact design.
- Flawless 4K@60Hz Video with HDMI: Delivers exceptional clarity and smoothness with its 4K@60Hz HDMI port, making it ideal for high-definition presentations and entertainment. (Note: Only the HDMI port supports video projection; the USB-C port is for data transfer only.)
- Double Up on Efficiency: The two USB-A 3.0 ports and a USB-C port support a fast 5Gbps data rate, significantly boosting your transfer speeds and improving productivity.
- Fast and Reliable 85W Charging: Offers high-capacity, speedy charging for laptops up to 85W, so you spend less time tethered to an outlet and more time being productive.
- What You Get: Anker USB-C Hub (7-in-1), welcome guide, 18-month warranty, and our friendly customer service.
<head>
<meta property="og:title" content="How to Create an Open Graph Image with Python">
<meta property="og:type" content="article">
<meta property="og:url" content="https://example.com/python-open-graph-image">
<meta property="og:image" content="https://example.com/images/og-image.png">
<meta property="og:image:alt" content="A dark blue graphic with the title How to Create an Open Graph Image with Python">
<meta property="og:image:type" content="image/png">
<meta property="og:image:width" content="1200">
<meta property="og:image:height" content="630">
</head>
Replace the example domain and page details with the real canonical page and image URL. The protocol permits repeated properties and defines ordering behavior for them; for a single generated image, one og:image declaration and its related properties are the straightforward case. See the Open Graph Protocol documentation for the basic and structured image properties.
Make the result dependable in production
- Bundle the font: an absolute path that works on a laptop may not exist in a container or deployment environment. Treat the font file as an application asset and verify its presence at startup or before rendering.
- Test long and unusual titles: test punctuation, accented characters, and long words. Text wrapping at spaces cannot break a single unspaced token, so shorten the title, allow a smaller font, or add logic for breaking long tokens when your content requires it.
- Check layout, not just fit: a title can remain inside the canvas yet look cramped or visually unbalanced. Preview real outputs and adjust padding, line spacing, font size limits, or alignment for the design.
- Serve the exact saved asset: make sure the URL in
og:imageresolves to the generated file and that the server delivers the intended image format. Keep the image URL aligned with the actual output filename and format.
Troubleshooting common problems
OSError: cannot open resource
Pillow cannot find or read the font file. Check that FONT_PATH points to a valid font in the runtime environment, that the file is included in the deployment, and that the process can read it.
Rank #4
- Dual Converters, Infinite Potential:Includes 2× USB C male to USB A female adapters and 2× USB A male to USB C female adapters. Perfect for a wide range of uses—tablets with Bluetooth keyboards, expand USB ports on macbook, and more. Two different converters for all your daily needs
- Next-Level 10Gbps & 3A Charging: No more slow 480Mbps, this usb to usb c adapter has a transfer speed of up to 10Gbps, allowing you to do more transferring in less time. This usb adapter fits both USB A and USB C charger, supporting up to 3A fast charging
- Upgraded Exquisite Craftsmanship: With an aluminum alloy housing and metal connector, the usbc to usb adapter is extremely durable and sturdy. Rigorously tested to withstand more than 10,000 times of plugging and unplugging, ensuring long-lasting performance
- Broad Compatible: The usb c to usb adapter widely supports all USB C/ USB A devices like laptops, tablets, cellphones, car chargers, and phone chargers. Such as compatible with MacBook Pro/Air 2023/2022, Thunderbolt 4/3 Devices,Apple MagSafe Watch 9/8/7/SE/Ultra, iPad Pro 2022/2021, Samsung Galaxy S23/S20/S10, and iPhone 17/16/15 Pro. Plug and play
- Please Note: To reach 10Gbps speed, keep the cable under 3.3 ft. For USB A Male to USB C adapters, try flipping the USB C connector. USB C Male to USB A adapters support bidirectional 10Gbps transfer within 3.3 ft
Title is clipped or overlaps the edge
The text may exceed the width or height after rendering, or the font’s glyph bounds may extend beyond its advance measurement. Reduce the maximum font size, increase padding or canvas dimensions, shorten the title, and inspect the rendered bounding boxes and image visually.
Unexpectedly different wrapping across environments
Different font files or versions can have different glyph metrics. Bundle the same font used during design and deploy that file alongside the script so the measured widths and visual layout remain consistent.
Best Value
- 5-in-1 Connectivity: Equipped with a 4K HDMI port, a 5 Gbps USB-C data port, two 5 Gbps USB-A ports, and a USB C 100W PD-IN port. Note: The USB C 100W PD-IN port supports only charging and does not support data transfer devices such as headphones or speakers.
- Powerful Pass-Through Charging: Supports up to 85W pass-through charging so you can power up your laptop while you use the hub. Note: Pass-through charging requires a charger (not included). Note: To achieve full power for iPad, we recommend using a 45W wall charger.
- Transfer Files in Seconds: Move files to and from your laptop at speeds of up to 5 Gbps via the USB-C and USB-A data ports. Note: The USB C 5Gbps Data port does not support video output.
- HD Display: Connect to the HDMI port to stream or mirror content to an external monitor in resolutions of up to 4K@30Hz. Note: The USB-C ports do not support video output.
- What You Get: Anker 332 USB-C Hub (5-in-1), welcome guide, our worry-free 18-month warranty, and friendly customer service.
Image is missing from a share preview
Check that og:image contains the public image URL, not a local filesystem path; verify the page includes the metadata in its head and that the URL is accessible to the service requesting it. The Open Graph metadata defines the reference, but platform-specific fetch and preview behavior should be checked against the target platform’s current guidance.
Or skip the browser setup
If you want a screenshot of a rendered page rather than a graphic drawn from text, ScreenshotNeo is a website screenshot API and MCP server. One GET request returns an image or PDF; its clean-shot options can accept cookie or consent banners and remove known consent platforms, newsletter popups, and chat widgets before capture. Its response identifies page verdict and billing status, and bot checks, blank pages, timeouts, failed loads, and cache hits are not billed. An MCP server provides screenshot tools for AI agents and other MCP clients. Free includes 1,000 shots per month with no card; paid plans start at $5 for 3,000.
For the exact image created in this guide, keep the Pillow workflow above. For a page capture, this cURL request saves a WebP screenshot:
curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://example.com -o shot.webp
See the ScreenshotNeo API documentation for request options. Sign up for 1,000 free screenshots a month with no card.
The Tool Desk
Outbyte Driver Updater FREEFix the driver behind crashes, sound loss and screen glitchesFind Drivers →Outbyte PC Repair FREEClear out junk files and repair common Windows errorsFree Scan →Quick Recap
Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

