Recommended Free Tools
Use PHP’s GD extension to create a PNG, save it at a stable public URL, then put that URL in the webpage’s og:image metadata. Image creation and social preview metadata are separate steps: generating a file alone does not tell a platform to use it. GD’s availability and supported formats depend on how PHP was built.
How the PHP image and webpage metadata work together
The Open Graph Protocol lets a webpage describe itself as a rich object. Its four basic properties are og:title, og:type, og:image, and og:url. The image is generated by your PHP code; the page HTML points social platforms to it.
As an Amazon Associate I earn from qualifying purchases.
- Create the image with GD and save it as a PNG, or stream it directly with PHP’s
imagepngfunction. - Make the saved image accessible at a stable, publicly fetchable URL.
- Add that full URL as the page’s
og:imagevalue alongside the other Open Graph properties. - Check image dimensions and file size against the rules of the platform where you intend to share the page.
The examples below use a saved asset because a persistent URL is straightforward to place in page metadata and serve independently of the PHP generation request.
Check that PHP supports GD and PNG
PHP’s image functions require GD support in the PHP build. Available formats can vary with the installed GD version and related libraries, so confirm support in the same environment that will run the code. Consult the PHP GD documentation and the PHP imagepng documentation.
#1 Best Overall
If GD is unavailable, enable or install a PHP build with GD support through your hosting environment, or use an image-generation route already supported by your application. Do not assume that a format supported on a development machine is supported on production.
Create a PNG with PHP GD
This runnable example creates a 1200 × 627 PNG with a solid background and text, then saves it as social-preview.png beside the PHP script. It uses PHP’s built-in bitmap font for a minimal dependency-free example; for production design, you can use GD’s text functions with a TrueType font and your own layout.
<?php
$width = 1200;
$height = 627;
$image = imagecreatetruecolor($width, $height);
if ($image === false) {
http_response_code(500);
exit('Could not create image');
}
$background = imagecolorallocate($image, 22, 44, 74);
$foreground = imagecolorallocate($image, 255, 255, 255);
imagefill($image, 0, 0, $background);
imagestring($image, 5, 50, 50, 'A generated social preview', $foreground);
$outputPath = __DIR__ . '/social-preview.png';
$saved = imagepng($image, $outputPath);
imagedestroy($image);
if (!$saved) {
http_response_code(500);
exit('Could not save PNG');
}
echo 'Saved ' . $outputPath;
Deploy the resulting file where your web server can serve it publicly, then use its full HTTPS URL in the page metadata. The example checks image creation and save success; production code should also handle its chosen output directory, permissions, and any design-specific text or image inputs.
Rank #2
Add Open Graph tags to the webpage
Put metadata in the page’s <head>. Replace the example URLs and text with values for the actual page. Do not emit duplicate conflicting values: the Open Graph Protocol says the first tag takes preference when values conflict.
<head>
<title>A useful page title</title>
<meta property="og:title" content="A useful page title">
<meta property="og:type" content="website">
<meta property="og:url" content="https://example.com/article">
<meta property="og:image" content="https://example.com/social-preview.png">
<meta property="og:description" content="A short description of the page.">
</head>
The URL in og:image must identify the image, not the PHP source file, unless that PHP endpoint is deliberately configured to return the image. Keep the image reachable to social crawlers; a path that works only in a logged-in browser will not provide a usable public preview.
Save the PNG or stream it from PHP
imagepng can write to a filesystem path or stream; omitting its file argument sends image data directly as output. Saving gives you a stable asset URL to reference from metadata. Streaming is useful when an endpoint is intentionally responsible for serving the generated image, but then the endpoint’s response must be handled as an image rather than as an HTML page.
Rank #3
For a basic streaming endpoint, send the image content type before output and ensure no warnings, whitespace, or other text is printed into the response:
Do these 3 things before closing this tab:
1Scan for outdated or missing drivers - takes under a minute2Repair Windows errors before they cause bigger problems3Fix the driver behind crashes, sound loss and screen glitches<?php
$image = imagecreatetruecolor(1200, 627);
$background = imagecolorallocate($image, 22, 44, 74);
imagefill($image, 0, 0, $background);
header('Content-Type: image/png');
imagepng($image);
imagedestroy($image);
Streaming does not itself add the endpoint URL to a webpage’s Open Graph metadata. If you choose this approach, put the endpoint’s publicly accessible URL in og:image.
Choose dimensions for the target platform
There is no single platform-wide image size established by the sources cited here. LinkedIn’s website-sharing guidance lists a minimum of 1200 × 627 pixels, recommends a 1.91:1 ratio, and sets a 5 MB maximum for sharing-module images. These are LinkedIn-specific figures, not universal social preview requirements. LinkedIn also says images under 401 pixels wide display as thumbnails.
Rank #4
LinkedIn’s help page was last updated in 2024, according to the page’s update label as accessed in 2026. Its separate specifications for single-image advertisements are not the same as the website-sharing module rules. For other social and messaging platforms, check their current official guidance rather than assuming LinkedIn’s requirements apply.
Common problems and fixes
- Undefined GD functions: The PHP runtime executing the script may not have GD enabled. Check the deployment’s PHP build and enable GD there; a different local PHP configuration does not establish production support.
- PNG creation or save fails: Confirm that the build supports PNG and that PHP can write to the target directory. Check the result of
imagepngrather than assuming the file was created. - The social card has no image: Confirm that
og:imagecontains the full public image URL and that the URL serves the image rather than a PHP error or an HTML page. - The page shows outdated or unexpected metadata: Inspect the rendered page head for duplicate Open Graph properties. The protocol gives the first conflicting value preference, so remove duplicates or make their order and values intentional.
- The image is rejected or displayed as a thumbnail on LinkedIn: Compare it with LinkedIn’s sharing-module requirements: minimum 1200 × 627 pixels, recommended 1.91:1 ratio, and maximum 5 MB; images below 401 pixels wide are identified as thumbnail display.
- Output is corrupted when streaming: Ensure the content-type header is sent before the image bytes and prevent notices, debug text, or whitespace from being emitted into the response.
Or skip the browser setup
If your goal is to capture a webpage as an image rather than design a branded graphic with GD, ScreenshotNeo is a website screenshot API and MCP server. A GET request returns a screenshot or PDF; it can also remove known consent banners, newsletter popups, and chat widgets before capture. The generated image still needs to be referenced as og:image on your page.
What’s actually slowing this PC down?
Pick the symptom - the matching free tool is one click away.
For example, this cURL request captures a webpage as WebP:
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 documentation for API details and response behavior. Cookie banners, popups, and chat widgets are removed before the shot; bot checks, blank pages, and failed loads are never billed. Its MCP server lets AI agents take screenshots. The free plan includes 1,000 screenshots a month with no card, and paid plans start at $5 for 3,000. Sign up for the free plan.
Implementation checklist
- Verify GD and PNG support in the PHP environment that will run the generator.
- Generate and save a valid image, checking for creation and write errors.
- Serve the image at a stable public URL.
- Set one intentional value each for
og:title,og:type,og:url, andog:image. - Check the image against the intended platform’s own current limits.
Frequently Asked Questions
Can PHP create the preview image dynamically on every request?
Yes. PHP’s imagepng can stream image data, but the page still needs to reference the image-serving endpoint in og:image.
Does creating a PNG automatically make it appear in a social link preview?
No. The webpage must expose the image URL through metadata such as og:image.
Quick wins for a faster PC:
Repair Windows errors before they cause bigger problemsFix Now →Fix the driver behind crashes, sound loss and screen glitchesFind Drivers →Is 1200 × 627 the right size for every social platform?
No. That is LinkedIn’s stated minimum for its website-sharing module; requirements vary by platform.
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.




