URL to JPEG with PHP

Screenshot webpages as JPEG with PHP

No browser management required

Capture public webpages from PHP with the html-css-to-image/client Composer package without installing Chrome, running a PHP headless-browser wrapper, or maintaining screenshot storage and delivery.

  • No browser processes to maintain
  • Full-page and selector controls included
  • Complete PHP request below
Real URL screenshot API requests followed by their rendered webpage images.
Request
POST https://hcti.io/v1/image
{
"url": "https://google.com",
"format": "jpeg",
"viewport_height": 480,
"viewport_width": 640
}
https://google.com
Screenshot of Google in a small viewport

PHP workflow

Test the webpage capture before adding it to PHP

Choose the URL and browser state here, then use the PHP example below instead of rebuilding the screenshot workflow locally.

Loading playground…

Managed screenshots

Skip the fragile parts of native PHP screenshot automation

Keep the application code focused on the request and response while HCTI manages Chromium, page loading, render isolation, retries, and hosted output.

No browser runtime to maintain

Avoid provisioning Chrome and long-running browser processes in PHP web or queue workers.

Screenshot controls are already modeled

Set the viewport, full-page mode, selector, timing, color scheme, and browser state as request parameters instead of browser scripts.

A usable image URL immediately

Receive the hosted .jpeg result without building a separate pipeline for temporary files, uploads, storage, and delivery.

URL screenshot API

Send one PHP request instead of running a browser

POST the webpage URL, capture settings, and format from PHP. HCTI handles the browser lifecycle and returns the generated .jpeg URL.

  • Public webpage URL

    Send the URL to load, including webpages whose final state depends on browser-rendered JavaScript.

  • JPEG output

    Set format to jpeg and use the hosted .jpeg URL returned by the API.

  • Viewport and crop controls

    Set viewport dimensions, capture the full page, or crop the result to a CSS selector.

  • Browser environment

    Choose color scheme, timezone, mobile behavior, timing, and other page-loading controls.

POST https://hcti.io/v1/image request example.
Request
POST https://hcti.io/v1/image
{
"url": "https://example.com",
"format": "jpeg",
"viewport_width": 1200,
"viewport_height": 630
}

How it works

From webpage URL to a finished JPEG

  1. Send the webpage URL

    Submit a public URL with format set to jpeg and any viewport, selector, or browser settings.

  2. Chromium loads the page

    The API runs the webpage, styles, fonts, images, and JavaScript in a managed browser environment.

  3. Use the .jpeg URL

    Embed the hosted result, download the file, or save it in your own storage and application records.

Example code

Screenshot a webpage as JPEG in PHP

Copy a complete PHP request. Authentication, the webpage URL, viewport settings, output format, and response handling are shown together.

<?php
// composer require html-css-to-image/client

use HtmlCssToImage\HtmlCssToImageClient;
use HtmlCssToImage\ImageFormat;
use HtmlCssToImage\Request\CreateUrlImageRequest;
use HtmlCssToImage\Response\CreateImageSuccessResponse;

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

$client = HtmlCssToImageClient::fromEnvironment();
$request = new CreateUrlImageRequest(
    url: "https://example.com",
    format: ImageFormat::JPG,
    viewportHeight: 630,
    viewportWidth: 1200,
);

$result = $client->createImage($request);
if ($result instanceof CreateImageSuccessResponse) {
    printf("%s\n", $result->url);
} else {
    fprintf(STDERR, "%s\n", $result->error);
}

Ready to capture?

Take your first JPEG webpage screenshot

Send a public URL to the API and receive a hosted .jpeg image without running browser infrastructure.