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

To generate an Open Graph image in Swift, render your artwork to a bitmap, publish that file at a stable public URL, then point your page’s og:image metadata to it. Use SwiftUI’s ImageRenderer for a card built from SwiftUI views, or UIKit’s UIGraphicsImageRenderer when you want explicit drawing control. The image file and the metadata are separate: creating one does not automatically configure the other.

Choose a rendering approach

The right renderer depends on how you want to build the card. Both approaches produce image output, but neither publishes the file or adds Open Graph tags to your website.

SwiftUI: render a view

Use ImageRenderer when the design is naturally a SwiftUI composition: text, shapes, images, gradients, and other content SwiftUI draws. Define the card at a deliberate size, then pass the view to the renderer and export its image output or draw through its Core Graphics context. This keeps the visual layout expressed as a SwiftUI view rather than recreating it with drawing commands.

Apple documents exporting bitmap data from SwiftUI views with ImageRenderer. It also documents drawing into a Core Graphics context. Keep the card’s essential artwork within content the renderer can capture: Apple warns that content rendered by native UIKit or AppKit frameworks—including web views and media players—may not appear as expected. If your design depends on such content, replace it with supported drawing elements or use UIKit/Core Graphics for those parts.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
#1 Best Overall
Elebase USB to USB C Adapter for iPhone 18 Pro Max,USBC Car Charger Adapter
  • 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.

UIKit and Core Graphics: draw explicitly

Use UIGraphicsImageRenderer when you want to issue drawing instructions directly. Create a renderer for the intended image size, draw the background, text, artwork, and branding in its drawing closure, then request a UIImage, PNG data, or JPEG data. Apple documents these output options and renderer format configuration.

This approach gives you explicit control over drawing, but you are responsible for positioning and laying out each element. For a card with many reusable SwiftUI components, rendering a SwiftUI view may be a more natural fit; for Core Graphics work or a drawing pipeline that needs PNG or JPEG bytes, UIKit’s renderer offers direct output methods. The available sources establish these different integration models, not a speed ranking.

Set the canvas for your destinations

Choose a canvas size and layout for the services where you expect the page to be shared. Do not treat 1200×630 pixels as a requirement of the Open Graph protocol: the protocol defines metadata properties, not one universal image dimension. The OG Image Generator recommends that size for its own templates, but that is the generator’s guidance, not a protocol mandate. Check the current requirements of your target sharing platforms and inspect the resulting previews.

Rank #2
Anker USB-C Hub, 5-in-1 USB Hub for Laptops, 4K HDMI Multiport Adapter
  • 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.
  • Design the card at a fixed, intentional size rather than letting its dimensions emerge accidentally from view content.
  • Keep important text and branding within the visual area you want displayed in previews.
  • Choose PNG or JPEG according to the artwork and the output you want. UIKit’s renderer documents both encoded formats; set metadata to match the file you actually publish.
  • Use the same measured pixel dimensions in the metadata only when they accurately describe the published image.

Render and publish the image

  1. Build the artwork. Implement the card as a SwiftUI composition for ImageRenderer, or draw it in a UIGraphicsImageRenderer closure.
  2. Encode the output. Obtain the rendered image or encoded PNG/JPEG bytes. For UIKit, the renderer exposes image, PNG-data, and JPEG-data outputs.
  3. Save or upload the bytes. Put the generated file somewhere your site can serve. The destination must remain available to the page’s sharing crawlers; a local file path on your development machine is not a public image URL.
  4. Use the hosted URL in your page metadata. Set og:image to the absolute URL of the image you published, not the location where the Swift code wrote it locally.
  5. Check a real preview. Inspect the page in the destinations where it will be shared. Do not assume every crawler updates a preview as soon as tags change; current cache-refresh behavior and every platform’s image limits are not established here.

Add Open Graph metadata to the page

The Open Graph protocol’s four basic required properties are og:title, og:type, og:image, and og:url. Its image structured properties include MIME type, width, height, secure URL, and alt text. The protocol advises supplying image alt text when an og:image is specified. Include values that describe the actual page and hosted file:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
<meta property="og:title" content="Article title" />
<meta property="og:type" content="website" />
<meta property="og:url" content="https://example.com/article" />
<meta property="og:image" content="https://example.com/images/article-card.png" />
<meta property="og:image:type" content="image/png" />
<meta property="og:image:width" content="1200" />
<meta property="og:image:height" content="630" />
<meta property="og:image:alt" content="A concise description of the image" />

Replace the example title, canonical page URL, image URL, and description with real values. The example dimensions only make sense if the published file really has those dimensions; they are not required values imposed by the protocol. If you use JPEG, identify the file as JPEG rather than leaving the example’s PNG MIME type in place.

Generate a page screenshot instead of a designed card

A screenshot can be a suitable image when the goal is to show a particular page or rendered interface, rather than a designed social card. It is a different workflow from rendering SwiftUI artwork: a screenshot service captures a URL, while ImageRenderer and UIGraphicsImageRenderer generate an image from your app’s view or drawing instructions. If the page is private, dynamic, or should not be exposed to crawlers, do not substitute its screenshot URL for a deliberately published Open Graph asset.

Rank #3
Sale
Anker USB C Hub, 7in1 Multi-Port USB Adapter, 4K@60Hz USBC to HDMI Splitter
  • 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.

For a captured page to serve as an Open Graph image, you still need a stable, publicly retrievable image URL and matching metadata. Screenshot output is not a replacement for those page tags, and a screenshot of a web page is not automatically equivalent to a purpose-built, branded social card.

Or skip the browser setup

For a screenshot-based image, ScreenshotNeo takes a URL and returns a PNG, JPEG, WebP, or PDF. It does not replace Swift rendering when you need a custom SwiftUI or Core Graphics design. One GET request can capture a page:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
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 API documentation for request options and response details. Cookie and consent banners, newsletter popups, and chat widgets are removed before capture; those cleanup steps can be turned off. Bot checks or CAPTCHAs, blank pages, timeouts, failed loads, and cache hits are not billed, with response headers indicating the page verdict and billing status. Its MCP server gives AI agents tools for taking screenshots, getting page information, and capturing PDFs. The free plan includes 1,000 screenshots per month with no card; paid plans start at $5 for 3,000.

Sign up for ScreenshotNeo’s free plan to get 1,000 screenshots a month with no card.

Rank #4
Sale
UGREEN USB to USB C Adapter Combo 4-Pack, 10Gbps USB C Converter Space Gray
  • 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

Choose between the available workflows

Approach Best fit Output and integration Important limitation
SwiftUI ImageRenderer A card designed as a SwiftUI view Rasterized view/image or drawing into a Core Graphics context May not capture content rendered by UIKit, AppKit, or other platform frameworks as expected.
UIKit UIGraphicsImageRenderer Explicit drawing instructions and Core Graphics work UIImage, PNG data, or JPEG data You are responsible for layout and drawing.
Browser-based image generator A one-off, manually designed image without a Swift generation pipeline The OG Image Generator documents PNG download and copyable metadata Its documented workflow is not a runtime or build-time Swift generation path; check its size guidance against the destinations you use.
ScreenshotNeo A screenshot of a URL, rather than a custom Swift-rendered card One GET request returns a screenshot in PNG, JPEG, or WebP, or a PDF A page capture does not create Swift artwork or add Open Graph tags to your page.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Troubleshoot missing or incorrect previews

The preview has no image

  • Confirm that the page has an og:image property and that its value is the absolute URL of the published image.
  • Open the image URL from outside your development environment. A local file path or an image that the page’s crawler cannot retrieve cannot serve as the public preview asset.
  • Check that the URL points to the file you intended to publish, and that the page metadata and uploaded asset were deployed together as expected.

The image is blank or missing part of the design

  • If you used ImageRenderer, inspect whether the missing elements depend on UIKit/AppKit rendering, a web view, or a media player. Apple warns that such content may not render as expected; use SwiftUI-rendered primitives or a UIKit/Core Graphics drawing path for the affected artwork.
  • If you used UIGraphicsImageRenderer, check the drawing instructions and layout. Explicit drawing means positions and content must be supplied by your code.

The preview is stale or does not match the file

  • Verify that og:image points to the current image and that the tags describe the current page.
  • Inspect the published file’s format and dimensions, then make its MIME type and any supplied dimension properties consistent with it.
  • Check the preview again in the actual destination. Crawler cache-refresh behavior varies and is not established here, so a metadata change should not be assumed to appear everywhere immediately.

The card is cropped or difficult to read

  • Revisit the canvas layout for the intended platform mix. Open Graph itself does not require one universal image size.
  • Test the actual preview destinations rather than relying on a single vendor’s template recommendation as a platform-wide guarantee.

Keep generation reliable in a build or publishing pipeline

For repeatable output, treat the artwork, encoding, upload, and metadata update as distinct steps. Generate the image with a known canvas, upload the resulting bytes, and only then publish or update the page tag to point at the final URL. That order avoids placing a new image URL in metadata before the asset is available. When regenerating cards, ensure that the URL you publish resolves to the intended version; the sources here do not establish a particular cache-busting strategy or crawler refresh schedule.

Choose whether the card is generated once, such as during a site build, or generated on demand as part of an application flow. The source documentation describes the rendering outputs but does not establish comparative performance benchmarks for SwiftUI versus UIKit, so make that choice based on the design and integration needs rather than an assumed speed advantage.

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

Finally, validate both sides of the result: the bitmap at its public URL and the page’s Open Graph tags. A correctly rendered local image with missing metadata will not define the page’s Open Graph image, and correct metadata pointing to an unavailable or incorrect file will not produce the intended preview.

Best Value
Anker USB C Hub, 5-in-1 USBC to HDMI Splitter with 4K Display
  • 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.

Frequently Asked Questions

Does Open Graph require an image to be 1200×630 pixels?

No. The protocol does not mandate one universal image size. That size is a recommendation for the OG Image Generator’s templates; check the current requirements of the platforms where you will share the page.

Can I use a SwiftUI view containing a web view as the image source?

Do not rely on it rendering correctly through ImageRenderer. Apple warns that content rendered by native platform frameworks, including web views and media players, may not be captured as expected.

Does generating the image in Swift automatically add Open Graph tags?

No. Swift creates the image data. Your web page must separately include the Open Graph metadata and point og:image to the hosted image.

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

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.