Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Generate a social preview image in Bash by filling a 1200×630 SVG template with safely escaped text, then rendering it to PNG with ImageMagick. Upload the PNG to a stable HTTPS URL and add that URL to your page’s Open Graph and Twitter card metadata; creating the file alone does not make it appear in link previews.

Choose the image format and dimensions

A 1200×630-pixel canvas is a common Open Graph image size, documented as the standard used by Twitter, LinkedIn, and Facebook in the current OG Image Generator documentation. It gives you a landscape image suitable for social previews. Platform display and cropping can vary, so keep important text and logos away from the outer edges and inspect the result at thumbnail size.

For a repeatable design, use SVG as the source and render a PNG for publication. SVG makes it straightforward to define a background, typography, accent shapes, and image placement in one template. PNG is a practical delivery format for broad social-preview compatibility. If your design is only a few simple shapes and labels, ImageMagick can draw the raster image directly instead.

Install and verify ImageMagick

The examples use the current ImageMagick command name, magick. Install ImageMagick using the package manager or installer for your operating system, then check that the command works:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
#1 Best Overall
Dell Optiplex 7050 SFF Desktop PC Intel i7-7700 4-Cores 3.60GHz 32GB DDR4 1TB SSD WiFi BT HDMI Duel Monitor Support Windows 11 Pro Excellent Condition(Renewed)
  • Model: Dell OptiPlex 7050 Small Form Factor (SFF)
  • Processor: Intel Core i7-7700 3.60 GHz
  • Memory: 32GB DDR4 Ram
  • Storage: 1TB Solid State Drive (SSD) Fast Boot + Storage
  • Operating System: Windows 11 Pro (64-bit)
magick -version

ImageMagick’s ability to render SVG depends on the installed rendering delegate and font support. Its format documentation says it uses Inkscape by default when it is in the execution path, otherwise RSVG. Your environment may differ, so verify rendering on the machine or build image that will generate your cards.

Generate a PNG from a parameterized SVG template

This Bash script accepts a title, subtitle, and output filename. It writes a 1200×630 SVG to a temporary file and asks ImageMagick to render it as PNG. The script requires Python 3 for XML escaping; that keeps shell quoting and XML escaping separate instead of interpolating arbitrary user text directly into markup.

#!/usr/bin/env bash
set -euo pipefail

if [[ $# -lt 1 ]]; then
  printf 'Usage: %s TITLE [SUBTITLE] [OUTPUT.png]n' "$0" >&2
  exit 2
fi

title=$1
subtitle=${2:-"A generated social preview"}
out=${3:-og-image.png}

svg=$(mktemp --suffix=.svg)
trap 'rm -f "$svg"' EXIT

TITLE="$title" SUBTITLE="$subtitle" python3 - "$svg" <<'PY'
import html
import os
import sys
from pathlib import Path

title = html.escape(os.environ["TITLE"], quote=True)
subtitle = html.escape(os.environ["SUBTITLE"], quote=True)
# XML does not allow literal line breaks inside an attribute or text run;
# replace them with spaces for this single-line template.
title = " ".join(title.splitlines())
subtitle = " ".join(subtitle.splitlines())
svg = f'''<svg xmlns="http://www.w3.org/2000/svg" width="1200" height="630" viewBox="0 0 1200 630">
  <rect width="1200" height="630" fill="#111827"/>
  <rect x="72" y="72" width="10" height="486" rx="5" fill="#38bdf8"/>
  <text x="112" y="270" fill="#ffffff" font-size="64" font-family="DejaVu Sans">{title}</text>
  <text x="112" y="345" fill="#cbd5e1" font-size="32" font-family="DejaVu Sans">{subtitle}</text>
</svg>'''
Path(sys.argv[1]).write_text(svg, encoding="utf-8")
PY

magick "$svg" "PNG:$out"
printf 'Wrote %sn' "$out"

Save it as make-og.sh, make it executable with chmod +x make-og.sh, and run, for example, ./make-og.sh "Bash for social images" "A repeatable build step" public/og-image.png. The output directory must already exist. The script deliberately puts XML-sensitive characters through an escaping step; do not replace that step with raw shell interpolation if titles can come from users or a content database.

This simple layout puts each text value on one line. Long titles can run past the canvas: shorten them, add SVG line wrapping with separate text elements, or use a layout system that measures and wraps text. Font availability and metrics can differ by machine, so verify line breaks and placement in the same environment used for production.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Rank #2
Apple 2026 MacBook Neo 13-inch Laptop with A18 Pro chip: Built for AI and Apple Intelligence, Liquid Retina Display, 8GB Unified Memory, 256GB SSD Storage, 1080p FaceTime HD Camera; Blush
  • AN AMAZING MAC AT A SURPRISING PRICE — With an incredibly portable and durable aluminum design, up to 16 hours of battery life,* and the A18 Pro chip, MacBook Neo is ready to go wherever school takes you.
  • FOUR STUNNING COLORS. ONE DURABLE DESIGN — Choose from four beautiful colors — Silver, Blush, Citrus, or Indigo — each with a color-coordinated keyboard. And MacBook Neo is made with a durable recycled aluminum enclosure that helps it reach 60 percent recycled content by weight — the most ever in any Apple product.*
  • FLY THROUGH EVERYDAY ASSIGNMENTS — Whether you’re cramming for finals, using Apple Intelligence* to summarize class notes, creating presentations, or even playing the latest Apple Arcade game,* MacBook Neo delivers the performance and AI capabilities you need to get things done.
  • UP TO 16 HOURS OF BATTERY LIFE — MacBook Neo delivers all day battery life, so you can power through from early morning classes to late night study sessions without worrying about plugging in.
  • A VIBRANT 13-INCH DISPLAY* — The gorgeous Liquid Retina display on MacBook Neo supports 1 billion colors, so photos and videos pop and text is crisp for easy reading.

Use direct ImageMagick drawing for a simpler card

When an image has no layered layout or reusable SVG assets, direct drawing removes the intermediate template. This example creates a solid background and places a single title using ImageMagick’s drawing options:

title='Bash for social images'
magick -size 1200x630 xc:'#111827' 
  -fill white -font DejaVu-Sans -pointsize 56 
  -gravity center -annotate +0+0 "$title" 
  PNG:og-image.png

Use a template instead when you need multiple text elements, precise relative positioning, logos, or version-controlled design changes. Quote shell variables as shown, and do not build command strings with user input and evaluate them as shell code. ImageMagick option behavior and available fonts can vary by installation.

Check the file before publishing

Confirm the format and dimensions, then open the image or inspect it at small size. ImageMagick can report the dimensions and format:

magick identify og-image.png
  • Check that the output is PNG and measures 1200×630.
  • Confirm the title is legible at the small size used in a link preview and does not touch the edges.
  • Check that the named font is installed and that punctuation, accents, and other characters render as intended.
  • Make sure the image is reachable from the public internet over HTTPS at its final URL.

To inspect fonts visible to ImageMagick where supported, run magick -list font. ImageMagick can also report how it handles SVG conversion, but the selected delegate depends on what is installed and available in the execution path.

What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Rank #3
Sale
HP Essential 2026 Laptop Student Business, Ultra Light, 4GB RAM, Intel CPU
  • Performance: Powered by Intel Celeron N4500 dual-core processor with up to 2.8 GHz burst frequency and 4MB L3 cache, this HP Chromebook delivers smooth multitasking for everyday computing. With 4GB LPDDR4x-2933 RAM and Intel UHD Graphics, enjoy seamless web browsing, video streaming, and productivity apps. Chrome OS boots in seconds and updates automatically, keeping your laptop secure and running at peak performance for students, professionals, and home users.
  • Immersive 14-Inch HD Display: Experience clear, vibrant visuals on the 14-inch diagonal HD (1366 x 768) anti-glare display with 250 nits brightness and 62.5% sRGB color accuracy. The micro-edge design maximizes your viewing area with an impressive 80% screen-to-body ratio, perfect for streaming movies, video calls, and document editing. The anti-glare coating reduces eye strain during extended use, making it ideal for all-day productivity and entertainment in any lighting condition.
  • Advanced Connectivity & Ports: Stay connected with Wi-Fi 6 (2x2) for faster wireless speeds and Bluetooth 5.3 for seamless device pairing. Equipped with versatile ports including 1 USB Type-C 10Gbps (with USB Power Delivery and DisplayPort 1.4), 2 USB Type-A 5Gbps ports, 1 HDMI 1.4b, and 1 headphone/microphone combo jack. Connect external monitors, transfer files quickly, charge your device, and expand your workspace effortlessly for maximum productivity and flexibility.
  • All-Day Battery & Premium Design: The battery keeps you powered throughout your day, while the included 45W USB Type-C power adapter ensures fast charging. Featuring a sleek modern grey finish with vertical brushing pattern on the keyboard deck, this lightweight 3.35 lb Chromebook combines style and portability. The full-size modern grey keyboard and HP Imagepad provide comfortable typing and precise navigation for work, school, or entertainment on the go.
  • Enhanced Security & Multimedia: Built-in H1 secure microcontroller protects your data and privacy with enterprise-grade security. The HP True Vision 720p HD camera with integrated dual array digital microphones delivers crystal-clear video calls and online meetings. HD Audio with stereo speakers provides rich, immersive sound for music, videos, and calls. With 64GB eMMC storage, you have ample space for essential files while Chrome OS seamlessly integrates with Google Drive for cloud storage.

Publish the image and add page metadata

Upload the PNG to a stable, publicly reachable URL, then place the absolute URL in the metadata for the page being shared. The Open Graph fields below include the image URL and its dimensions; the Twitter card fields request a large-image card.

<meta property="og:image" content="https://example.com/assets/og-image.png">
<meta property="og:image:width" content="1200">
<meta property="og:image:height" content="630">
<meta name="twitter:card" content="summary_large_image">
<meta name="twitter:image" content="https://example.com/assets/og-image.png">

Replace the example URL with the exact public asset URL. Serve the metadata in the page’s HTML response and make sure the page itself can be fetched by the platform that builds the preview. If you update an image but a social preview still shows an older version, change the asset URL or cache key and verify that the page now exposes the updated absolute URL.

Choose between local generation and a hosted API

Local ImageMagick generation suits build pipelines that need repeatable output, work offline, or keep source content and assets within their own environment. Its trade-off is operational: your build machines need ImageMagick, an SVG rendering delegate when using SVG, and the fonts and assets the design expects.

A hosted screenshot API is a different tool from the SVG-to-PNG workflow above: it captures a rendered web page rather than drawing a card from a local template. It can be useful when the source of the image is already a web page or when you want to avoid installing and maintaining browser rendering infrastructure. Choose based on the input you have and how much control you need over the final design.

Free tools Windows power users keep installed

One-click scans. No signup required.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Rank #4
Dell Optiplex 3060 Desktop Computer | Intel i5-8500 (3.2) | 32GB DDR4 RAM | 1TB SSD Solid State | Built in WiFi | Bluetooth | Windows 11 Professional | Home or Office PC (Renewed)
  • [INTEL POWERED CONTENT] - Built with a 8th Generation Hexa-Core Intel i5 and 32GB of DDR4 RAM; Modern, Windows 11 ready, with 4K support, Executive multitasking, media streaming and smooth, multi-tab web browsing; Perfect as an all-purpose multimedia computer; built for content creators; Plenty of RAM and Mass storage for photo and video editing powered by Intel HD 630
  • [LATEST WIRELESS TECH] - This Dell Desktop Computer easily connects to the internet through the Built In WiFi / Bluetooth
  • [SOLID STATE STORAGE] - This Dell Computer setup comes with an ultra-fast 1TB Solid State Drive (SSD); Setup as the primary boot device; Boot and load programs with lightning speed ; Additional expansion available
  • [BUY & OWN WITH CONFIDENCE] - From the world's largest Microsoft Authorized Refurbisher; Quality Guarantee and Free Tech Support; Award-winning Customer Service; | Support Sustainable Business
  • [MODERN HI-SPEED PORTS] - USB 3.0 (x4) | USB 2.0 (x4) | DisplayPort (x1) | HDMI Port (x1) | Audio Combo Jack (x1) | Audio Out (x1) | RJ-45 Ethernet (x1) | Internal SATA (x3)

Or skip the browser setup

If your social image is already a web page and you want a screenshot rather than a hand-built SVG, ScreenshotNeo offers a website screenshot API and MCP server. One GET request returns an image or PDF. For example, 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://stripe.com -o shot.webp

See the ScreenshotNeo documentation for API details. ScreenshotNeo removes supported cookie and consent banners, newsletter popups, and chat widgets before capture; bot checks, blank pages, and failed loads are not billed. Its MCP server lets AI agents take screenshots, and the free plan includes 1,000 shots per month without a card; paid plans start at $5 for 3,000. This is a hosted capture option, not a replacement for the local SVG method when you need to compose a bespoke card.

Sign up for ScreenshotNeo’s free plan: 1,000 screenshots a month, no card required.

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Troubleshoot rendering and previews

The script says the ImageMagick command is missing

ImageMagick may not be installed, or your shell may expose a different command name. Install it for your operating system and verify with magick -version. If your environment provides another ImageMagick entry point, adjust the script to that installed command and test the output explicitly.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

The SVG fails to render or looks different on another machine

Check which SVG delegate is installed and selected. ImageMagick’s format documentation describes Inkscape as the default when available in the execution path, otherwise RSVG. Differences in delegate versions, fonts, and font metrics can change rendering. Install and pin the renderer and fonts in the build environment when consistent output matters.

Best Value
Dell OptiPlex Computer Desktop PC, Intel Core i5 3rd Gen 3.2 GHz, 16GB RAM, 2TB HDD, New 22 Inch LED Monitor, RGB Keyboard and Mouse, WiFi, Windows 11 Pro (Renewed)
  • 🖥POWERFUL PROCESSOR and SUPERIOR STORAGE: Configured with top of the Intel Core i5 processor for lightning-fast, reliable and consistent performance to ensure an exceptional PC experience. 16GB RAM memory to smoothly run multiple applications and browser tabs all at once. 2TB HDD storage space to store apps, games, photos, music, and movies. Loaded with 16GB to zip through multiple tasks in a hurry without lag.
  • 🖥️New 22 Inch Full HD (1920x1080) LED monitor: with 75hz, High-Quality panel with quick refresh rate and response time. With 1080p resolution, you can enjoy gaming or a modern computing experience. 22 Inch monitor has a Smart Contrast to provide optimized image quality. Bezel-less and sleek design with glossy finish, crisp edge-to-edge visuals. Wide Viewing Angles for clarity from any viewpoint. VESA Mountable and built-in tilt options allow for a variety of monitor configurations.
  • ⌨️ +🖱️ RGB KEYBOARD AND MOUSE | RGB SPEAKER: 3 LED Colors - Blue, red, green, Backlight LED Lights for use at night time, looks amazing. The keyboard mouse and speaker are responsive, reliable, and probably plastered in RGB lights. It's important you pick the right one for your desktop.
  • 💿 WINDOWS 10 Pro LATEST: A new installation of the latest Microsoft Windows 11 Professional 64 Bit Operating System software, free of bloatware commonly installed from other manufacturers. As Microsoft's latest and best OS to date, Windows 10 Pro 64 Bit will maximize the utility of each PC for years to come. Optional software such as Anti-Virus and Office 365 can also be easily downloaded through the Microsoft Windows App Store.

Text is missing or substituted

Verify that the font named in the SVG or ImageMagick command is installed and visible to ImageMagick. Run magick -list font where supported, then choose a listed font or install the intended one in the build environment.

The generated file has the wrong dimensions or format

Run magick identify og-image.png and check the reported format and dimensions. Keep the canvas at 1200×630 and explicitly use the PNG output prefix in the examples if a filename extension or ImageMagick configuration might select another format.

Special characters break the image

Characters such as ampersands and angle brackets have meaning in XML. The SVG script escapes title and subtitle values before inserting them, and the direct drawing example quotes the title as one shell argument. For other implementations, preserve both protections: shell-safe argument handling and XML escaping. This example replaces newlines with spaces rather than rendering multiline titles.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

The social preview is stale or missing

Check that the page contains the current absolute image URL and that the image responds publicly over HTTPS. If a previously cached preview persists after an update, publish the changed asset under a new URL or cache key. A valid local PNG is not enough if the page metadata or public hosting is wrong.

Frequently Asked Questions

Does generating the PNG automatically add an Open Graph image to my page?

No. You must upload it to a public URL and set that URL in the page’s metadata.

Can I publish the SVG instead of a PNG?

SVG can be delivered where the consuming platform supports it, but the workflow here renders PNG for broad social-preview compatibility.

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.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.