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.

PHP’s imagejpeg() cannot convert HTML directly: it encodes an existing image. To make a JPEG from HTML, first render the HTML and CSS into pixels, then encode those pixels as JPEG. A PHP-oriented route is Dompdf to lay out the HTML as PDF, followed by Imagick to rasterize a PDF page and write a JPEG. For JavaScript-heavy pages or closer browser fidelity, use a real browser renderer or a hosted screenshot service instead.

Choose the rendering route first

HTML is a document description, not a bitmap. The conversion therefore has two distinct stages: layout and rendering, followed by rasterization and JPEG encoding. Which route fits depends on how closely the output needs to match a browser and what your PHP host can support.

Approach Best fit Important limitation
Dompdf → PDF → Imagick PHP applications that can accept a PDF intermediary and Dompdf’s HTML/CSS support. Dompdf is mostly CSS 2.1 compliant, not a full browser engine; its documented output is PDF.
GD imagejpeg() Encoding or saving an image that already exists as a GD image. GD does not render HTML.
Browser-based renderer or hosted screenshot API Investigating browser fidelity, JavaScript execution, or modern CSS. Verify the chosen renderer’s output formats, asset handling, security, and licensing for your use case.

Dompdf describes itself as a mostly CSS 2.1-compliant HTML layout and rendering engine written in PHP. It supports external stylesheets, UTF-8, common image formats, and selected CSS3 features, but its documentation warns that poorly formed HTML can cause problems. See Dompdf’s project documentation and feature notes.

Check the PHP environment

Before implementing the pipeline, confirm that the environment supports both stages. Dompdf requires relevant PHP extensions, including DOM and MBString. Imagick must be available to PHP, and the ImageMagick build must permit PDF input through its delegate and policy configuration. A hosting account may have Imagick installed but still disallow PDF reading.

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.
#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.
  • Check the PHP version and required extensions against the Dompdf version you install.
  • Confirm that the Imagick PHP extension is enabled and can read PDF input in the deployed environment.
  • Make sure the process can write to the destination directory and has enough memory for the rendered page.
  • Provide fonts and image assets in a way the renderer can access; remote asset loading and untrusted HTML need explicit security decisions.

Render HTML to PDF with Dompdf

Install Dompdf with Composer, then render a controlled HTML document to PDF. The following is a compact example for HTML you already have in your application. Store the HTML in a variable and use an application-controlled output path.

composer require dompdf/dompdf
<?php
require __DIR__ . '/vendor/autoload.php';

use DompdfDompdf;
use DompdfOptions;

$html = '<!doctype html>
<html>
<head>
  <meta charset="UTF-8">
  <style>
    body { font-family: DejaVu Sans, sans-serif; margin: 24px; }
    h1 { color: #183153; }
  </style>
</head>
<body>
  <h1>A PHP-rendered page</h1>
  <p>This HTML is laid out by Dompdf before it becomes an image.</p>
</body>
</html>';

$options = new Options();
$dompdf = new Dompdf($options);
$dompdf->loadHtml($html, 'UTF-8');
$dompdf->setPaper('A4', 'portrait');
$dompdf->render();

$pdfPath = __DIR__ . '/page.pdf';
file_put_contents($pdfPath, $dompdf->output());

Choose the paper size and orientation deliberately: they determine the PDF page dimensions and, downstream, the raster image proportions. For a single designed screen-like composition, give the source HTML explicit dimensions and ensure the resulting PDF page is sized to match the intended output. Dompdf’s CSS and HTML support is not identical to a browser, so validate the layout and typography with representative content.

Rasterize the PDF page and write a JPEG

With a PDF file available, Imagick can read a page, select JPEG as the output format, set compression quality, and write the resulting image. ImageMagick’s PDF reading depends on the installed build and its delegate policy, so test this exact operation on the server where the code will run.

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.
<?php
$pdfPath = __DIR__ . '/page.pdf';
$jpegPath = __DIR__ . '/page.jpg';

$image = new Imagick();
$image->setResolution(150, 150); // Set before reading the PDF.
$image->readImage($pdfPath . '[0]'); // [0] selects the first page.
$image->setImageFormat('jpeg');
$image->setImageCompression(Imagick::COMPRESSION_JPEG);
$image->setImageCompressionQuality(82);
$image->writeImage($jpegPath);
$image->clear();
$image->destroy();

The example selects only the first PDF page. If the document has multiple pages, process each page separately and define how the application names or returns those JPEGs. The code is an implementation shape based on Imagick’s documented format API; PDF input still needs to be enabled in the deployment. See PHP’s Imagick setImageFormat() documentation and ImageMagick’s supported formats.

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

Resolution controls raster dimensions: at a higher resolution, the same PDF page produces more pixels, which can improve fine detail but increase memory use and file size. Pick a resolution appropriate to the intended display or print use, then inspect the result. JPEG does not preserve transparency, so determine how transparent areas should appear before encoding; if a particular background matters, flatten onto it before saving.

Use GD when the image already exists

If another stage has already produced a GD image resource or object, PHP’s imagejpeg() writes it to a file or sends it to the response. It does not parse HTML, apply CSS, or execute JavaScript.

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.
<?php
// $im must already be a valid GD image.
$quality = 82;
imagejpeg($im, __DIR__ . '/output.jpg', $quality);
imagedestroy($im);

To stream the JPEG instead, send an appropriate response header and omit the filename argument:

<?php
header('Content-Type: image/jpeg');
imagejpeg($im, null, 82);
imagedestroy($im);

The PHP manual documents a quality range of 0–100. If omitted, the default -1 behavior uses the default IJG quality, about 75. Choose a value based on the balance between visible artifacts and file size, rather than assuming the same quality setting suits every image. See PHP’s imagejpeg() manual page.

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

Or skip the browser setup

If you need a browser-based screenshot rather than a PHP HTML-to-PDF pipeline, ScreenshotNeo is a website screenshot API and MCP server. One GET request can return PNG, JPEG, WebP, or PDF. Its capture options include full-page screenshots, CSS selectors, viewport and device settings, and waiting for a selector, a delay, or network idle. It also accepts cookie banners before capture and removes more than 60 known consent platforms, newsletter popups, and chat widgets; those steps can each be turned off.

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

For a JPEG response, request the JPEG format using the API’s documented parameters; see the ScreenshotNeo API documentation for the current parameter names and response details. The request above shows the one-call pattern. ScreenshotNeo reports whether a page was clean and whether it was billed in response headers; bot checks, blank pages, timeouts, failed loads, and cache hits cost nothing. Its MCP server offers take_screenshot, get_page_info, and capture_pdf for AI agents and MCP clients. The Free plan includes 1,000 shots per month with no card; paid plans start at $5 for 3,000 shots.

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

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

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

Improve fidelity and output quality

HTML and CSS

Use valid, well-formed markup and test the exact content shape you expect in production. Dompdf is not a full browser, and its CSS support has limits. Layouts that depend on browser-specific behavior, JavaScript-generated content, or unsupported CSS may differ from what you see in a browser.

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

Fonts and external assets

Text wrapping and visual appearance depend on the fonts available to the renderer. Check that required fonts are installed or embedded through a supported approach. For images and stylesheets, confirm that paths resolve from the rendering process, not merely from the browser on your workstation. Remote assets introduce network, access-control, and security considerations; do not accept arbitrary HTML or URLs without deciding what the server is allowed to fetch.

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.

Dimensions, color, and compression

The output pixel dimensions follow the PDF page size and rasterization resolution. Inspect JPEG text at its final intended size: aggressive compression can make small text and sharp edges look poor. Since JPEG is lossy and does not carry transparency, choose a deliberate background and quality setting. Measure memory use and render duration in the actual deployment; there are no general performance figures established for this pipeline.

Troubleshoot common failures

  • The output is blank or missing styling: verify that the HTML is valid, stylesheets load from the renderer’s environment, and the CSS features used are supported by Dompdf.
  • Images or fonts are absent: check paths, permissions, remote-resource policy, and whether the renderer can access each asset. Confirm that the desired font is installed or otherwise configured.
  • Imagick reports a PDF or delegate error: check whether the deployed ImageMagick build supports PDF input and whether its policy allows it. An enabled PHP extension alone does not prove PDF rasterization is permitted.
  • The JPEG is too small or blurry: increase PDF rasterization resolution, then check the resulting pixel dimensions and image size. Higher resolution increases resource use.
  • The page is cut off or split unexpectedly: adjust the HTML layout and PDF paper size/orientation, and check page breaks. For multi-page PDFs, decide explicitly whether to export each page or only the first.
  • Memory use is excessive: reduce the rasterization resolution, process one page at a time, and release Imagick objects after use. Large pages and high-resolution output require more memory.
  • The JPEG has an unexpected background or artifacts: account for JPEG’s lack of transparency and adjust flattening/background behavior and compression quality.

Security and operational considerations

Rendering untrusted HTML is not just a formatting task: remote assets can trigger server-side requests, and resource consumption can grow with page size and resolution. Set application-specific input, network, time, memory, and output limits, and use a controlled environment for content that is not trusted. The renderer and ImageMagick configuration should be reviewed for the deployment’s security requirements; no single configuration is appropriate for every application.

For a PHP-managed pipeline, monitor rendering time, peak memory, output dimensions, and JPEG size using representative pages. Track failures separately by stage—HTML/PDF rendering versus PDF/image conversion—so an unavailable font or blocked PDF delegate is not mistaken for a JPEG encoder problem.

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

Frequently Asked Questions

Can PHP’s imagejpeg() convert an HTML string directly?

No. It accepts an existing GD image; HTML must first be rendered into pixels.

Can this Dompdf approach execute JavaScript in the page?

Dompdf is an HTML/CSS renderer, not a documented PHP-native browser engine. The available documentation does not establish JavaScript execution; use a browser-based renderer when that behavior is required.

Can I get one JPEG for a multi-page PDF?

The sample selects page zero only. Export additional pages individually or define an explicit composition strategy for combining them.

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.