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

Use Spatie Browsershot to render HTML in headless Chrome, then explicitly select JPEG output before saving the image. Browsershot accepts either an HTML string or a URL; it is a PHP interface to Puppeteer and Chrome, not a pure-PHP HTML renderer.

What you need to convert HTML to JPG

HTML is a document description, not an image. To turn it into a JPG, your application first needs a browser engine to lay out the markup, apply CSS, and render the page. Browsershot provides the PHP interface for that browser-rendering step; Chrome produces the rendered page and the screenshot is encoded as JPEG.

That distinction matters when choosing a deployment environment. PHP alone is not enough: the server must be able to run the PHP package and the Node/Puppeteer/headless Chrome components required by the Browsershot setup you install. Check those runtime requirements against your hosting provider before building the feature around it; no particular host or deployment configuration is guaranteed by the package documentation.

Check the installed package requirements

Packagist lists Browsershot 5.4.0, released on May 26, 2026, with PHP ^8.2, ext-fileinfo, ext-json, spatie/temporary-directory ^2.0, and symfony/process ^6.0|^7.0|^8.0. Package requirements can change, so use the metadata for the version you actually install rather than treating those constraints as permanent.

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.
#1 Best Overall
Sale
Philips 24 Inch Computer Monitor FHD 100Hz VA VESA Flicker-Free, 241V8LB
  • CRISP CLARITY: This 23.8″ Philips V line monitor delivers crisp Full HD 1920x1080 visuals. Enjoy movies, shows and videos with remarkable detail
  • INCREDIBLE CONTRAST: The VA panel produces brighter whites and deeper blacks. You get true-to-life images and more gradients with 16.7 million colors
  • THE PERFECT VIEW: The 178/178 degree extra wide viewing angle prevents the shifting of colors when viewed from an offset angle, so you always get consistent colors
  • WORK SEAMLESSLY: This sleek monitor is virtually bezel-free on three sides, so the screen looks even bigger for the viewer. This minimalistic design also allows for seamless multi-monitor setups that enhance your workflow and boost productivity
  • A BETTER READING EXPERIENCE: For busy office workers, EasyRead mode provides a more paper-like experience for when viewing lengthy documents

Install the package in your project with Composer, then follow the current Browsershot setup instructions for the Node and browser runtime that match your system. A successful Composer installation alone does not prove Chrome is available or executable by the PHP process.

Convert an HTML string to a JPG

This example renders a self-contained HTML string at a 1200-by-800 browser viewport and saves a JPEG beside the PHP script. The quality value of 90 is an illustrative choice; Spatie’s image documentation demonstrates JPEG output with a quality setting of 100, not a universal best setting.

<?php

require __DIR__ . '/vendor/autoload.php';

use SpatieBrowsershotBrowsershot;

$html = <<<'HTML'
<!doctype html>
<html lang="en">
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <title>Example card</title>
  <style>
    body { font: 18px Arial, sans-serif; margin: 0; padding: 32px; }
    .card { background: #eef3ff; border-radius: 12px; padding: 24px; }
  </style>
</head>
<body>
  <article class="card">
    <h1>Hello from PHP</h1>
    <p>This HTML is rendered in a browser before it becomes a JPG.</p>
  </article>
</body>
</html>
HTML;

Browsershot::html($html)
    ->setScreenshotType('jpeg', 90)
    ->windowSize(1200, 800)
    ->save(__DIR__ . '/output.jpg');

The code uses setScreenshotType('jpeg', 90) deliberately. Browsershot’s documented screenshot output defaults to PNG, so a .jpg filename by itself is not enough to request JPEG encoding. The output directory must also exist and be writable by the PHP process.

Rank #2
Philips 22 Inch Computer Monitor FHD 100Hz VA VESA Flicker-Free, 221V8LB
  • CRISP CLARITY: This 22 inch class (21.5″ viewable) Philips V line monitor delivers crisp Full HD 1920x1080 visuals. Enjoy movies, shows and videos with remarkable detail
  • 100HZ FAST REFRESH RATE: 100Hz brings your favorite movies and video games to life. Stream, binge, and play effortlessly
  • SMOOTH ACTION WITH ADAPTIVE-SYNC: Adaptive-Sync technology ensures fluid action sequences and rapid response time. Every frame will be rendered smoothly with crystal clarity and without stutter
  • INCREDIBLE CONTRAST: The VA panel produces brighter whites and deeper blacks. You get true-to-life images and more gradients with 16.7 million colors
  • THE PERFECT VIEW: The 178/178 degree extra wide viewing angle prevents the shifting of colors when viewed from an offset angle, so you always get consistent colors

Render a webpage URL instead

When the source is a live webpage, pass its address to Browsershot::url() rather than downloading markup yourself. The rest of the JPEG configuration is the same:

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

require __DIR__ . '/vendor/autoload.php';

use SpatieBrowsershotBrowsershot;

Browsershot::url('https://example.com')
    ->setScreenshotType('jpeg', 90)
    ->windowSize(1200, 800)
    ->save(__DIR__ . '/page.jpg');

This asks the browser to visit the page, so the result depends on the page loading successfully in the server’s browser environment. Pages that rely on JavaScript, remote stylesheets, fonts, or images need those resources to be reachable and load correctly at capture time. For site-specific waiting, authentication, or rendering behavior, check the Browsershot usage documentation for the options supported by the version you use.

Convert a local HTML file

For a local file, one straightforward option is to read its contents and give the string to Browsershot:

Rank #3
Sale
Dell 24 Monitor - SE2426H - 23.8-inch FHD (1920x1080) 144Hz 1ms Display, in-Plane Switching (IPS) Technology, AMD FreeSync™, TÜV 3-Star 2X HDMI, Tilt
  • Clear visuals. Fluid motion: A 144Hz refresh rate and 1ms MPRT deliver smooth, tear‑free motion across work, gaming, and streaming for clearer, more fluid viewing.
  • Eye comfort: TÜV Rheinland 3‑star* certification reduces harmful blue light while preserving stunning color quality without compromise. *TÜV Rheinland 3-star eye comfort certification.
  • Wide viewing angle: Get consistent views across a wide 178° /178° viewing angle.
  • In-Plane Switching (IPS): See excellent color accuracy and consistency across wide viewing angles with In-plane Switching (IPS) technology.
  • Ultra-thin bezels: Maximize your viewing experience with thin bezels.
<?php

require __DIR__ . '/vendor/autoload.php';

use SpatieBrowsershotBrowsershot;

$html = file_get_contents(__DIR__ . '/page.html');
if ($html === false) {
    throw new RuntimeException('Could not read page.html');
}

Browsershot::html($html)
    ->setScreenshotType('jpeg', 90)
    ->windowSize(1200, 800)
    ->save(__DIR__ . '/page.jpg');

If the file refers to CSS, images, or fonts using relative paths, ensure those resources resolve from the rendered document. A practical fix is to use absolute URLs for assets or include the CSS and markup needed for the capture. A local HTML file that depends on its original directory structure may not look the same when its contents are rendered without that context.

Choose the capture size and region

The browser viewport controls the page layout, so set it to the dimensions your output needs. A narrow viewport can trigger mobile CSS; a wider one may select a desktop layout. The dimensions in windowSize(1200, 800) set a 1200-by-800 browser window, but that does not mean an entire long page will fit into an 800-pixel-tall image.

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

For a full-page capture, a clipped region, or a single element, use the corresponding Browsershot image options documented in Spatie’s image-creation guide. Full-page capture is useful for a long article or dashboard; clipping is useful when only a known part of the rendered page belongs in the image; element selection avoids capturing unrelated page content. Check the option names and behavior in the documentation for your installed version before adding one to production code.

Rank #4
Samsung 27" Essential S3 (S36GD) Series FHD 1800R Curved Computer Monitor
  • CURVED FOR ENHANCED ENGAGEMENT: An immersive viewing experience with a curved monitor that wraps more closely around your field of vision; It creates a wider view, enhancing depth perception and minimizing peripheral distraction
  • SMOOTH PERFORMANCE FOR SEAMLESS CONTENT: Stay in the action when playing games, watching videos, or working on creative projects; The 100Hz refresh rate reduces lag and motion blur so you don't miss a thing in fast-paced moments¹
  • MORE GAMING POWER: Gain the edge with optimizable game settings; Color and image contrast can be adjusted to see scenes more vividly and spot enemies hiding in the dark; Game Mode adjusts any game to fill the screen so you can view every detail²
  • KEEP IT EASY ON THE EYES: Care for your eyes and stay comfortable, even during long sessions; Advanced eye comfort technology certified by TÜV reduces eye strain by minimizing blue light and reducing irritating screen flicker²
  • INCREASED VERSATILITY: Connect to more; Plug devices straight into your monitor for increased flexibility, making your computing environment even more convenient

The image guide also documents base64 output when the image needs to be returned or embedded rather than written directly to a file. JPEG is lossy, so text-heavy pages, sharp interface borders, and small type may look less crisp than a lossless format. If JPEG is required, compare the resulting file and legibility at the dimensions you actually use instead of assuming the example quality value is ideal.

Or skip the browser setup

For a webpage URL, ScreenshotNeo provides a screenshot API and MCP server. Its API accepts a URL in one GET request and can return PNG, JPEG, WebP, or PDF. For example, this cURL request saves a JPEG-compatible WebP only if asked for WebP; as written it uses the service’s default response format, so specify the format required by your workflow in the request according to the ScreenshotNeo API documentation.

curl -G "https://api.screenshotneo.com/v1/shot" 
  -d access_key=YOUR_API_KEY 
  --data-urlencode url=https://example.com 
  -o shot.webp

ScreenshotNeo accepts and removes cookie or consent banners, newsletter popups, and chat widgets before capture; each cleanup step can be turned off. Bot checks and CAPTCHAs, blank pages, timeouts, failed loads, and cache hits are not billed, and responses include X-Page-Verdict and X-Billed headers. Its MCP server offers take_screenshot, get_page_info, and capture_pdf tools for AI agents and MCP clients. It can also render HTML/CSS to an image, but the example above is for a URL-based request.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Plan Monthly price Included screenshots per month
Free $0 1,000
Starter $5 3,000
Growth $15 15,000
Pro $39 60,000
Scale $99 250,000
Business $249 1,000,000

The Free plan requires no card; yearly billing gives two months free, and every listed feature is available on every plan. Sign up for 1,000 free screenshots a month with no card.

Best Value
Sale
Sceptre New 22-Inch Gaming Monitor, FHD 1080p, Up to 144Hz, HDMI, DisplayPort, Built-in Speakers, Machine Black (E225W-FW144 Series, 2026)
  • 【INTEGRATED SPEAKERS】Whether you're at work or in the midst of an intense gaming session, our built-in speakers provide rich and seamless audio, all while keeping your desk clutter-free.
  • 【EASY ON THE EYES】 Protect your eyes and enhance your comfort with Blue-Light Shift technology. This feature reduces harmful blue light emissions from your screen, helping to alleviate eye strain during long hours of use and promoting healthier viewing habits.
  • 【WIDEN YOUR PERSPECTIVE】Our sleek minimal bezel design ensures undivided attention. The nearly bezel-free display seamlessly connects in a dual monitor arrangement, delivering an unobstructed view that lets you focus on more at once, completely distraction-free.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Security and deployment considerations

If an application accepts HTML or URLs from users, validate those inputs before passing them to Browsershot. Spatie explicitly places responsibility for validating supplied HTML and URLs on the user. Browser rendering of untrusted input should be treated as a security-sensitive operation; validation is necessary, but the cited package documentation is not a complete security-hardening guide.

Also verify that your production PHP process can access the browser runtime, write to the destination directory, and reach any remote resources used by the page. Local development success does not establish that a restricted host has the same runtime or network access. The current package requirements can be checked on Packagist’s spatie/browsershot page.

Troubleshooting HTML-to-JPG conversion

  • The saved file is PNG or will not open as JPG: explicitly call setScreenshotType('jpeg', quality). Browsershot documents PNG as the default screenshot type, regardless of the filename extension.
  • Browsershot cannot start Chrome or Puppeteer: confirm the Node/Puppeteer/Chrome components required by the installed setup are present and available to the PHP process. Composer dependencies by themselves are not a browser runtime.
  • The image is blank or missing remote assets: check that the target URL and its CSS, image, font, or script resources can load from the server. For local HTML, replace unresolved relative asset paths with paths that are valid in the rendering context.
  • The image is cropped or the layout is unexpectedly narrow: adjust the viewport dimensions to match the intended responsive layout. For long pages or selected regions, use the documented full-page or clipping options rather than expecting a short viewport to include all content.
  • The output cannot be written: check that the output directory exists and is writable by the user running PHP, and that the output path is correct.
  • The page differs from what a person sees: inspect whether it depends on scripts or external resources that have not finished loading or are inaccessible in the server environment. Use Browsershot’s documented options for the installed version to adjust capture behavior.

Why PHP GD is not a substitute for browser rendering

PHP’s GD extension provides image creation and manipulation functions, including output functions such as imagepng. The PHP manual does not describe GD as a renderer for arbitrary HTML and CSS. Use a browser-based tool such as Browsershot to turn a webpage into pixels; use GD for image operations after you have an image, when those operations suit your use case. See the PHP GD documentation for the extension’s image functions.

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.

Frequently Asked Questions

Can a JPG keep a transparent background?

No. JPEG does not support transparency. If the rendered content needs transparent pixels, choose an image format that supports transparency instead of JPEG.

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.