URL to WebP with PHP

Screenshot webpages as WebP with PHP

No browser management required

Capture public webpages from PHP 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": "webp",
"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.

Options

Enter a public webpage URL.

Apply styles after the page loads and before the screenshot is captured.

Content

Adjust how content is rendered by adjusting these settings.
?

A CSS selector for an element in the HTML. We’ll crop the image to this specific element.

?

Removes the background from the rendered image.


Image size & Viewport

By default images are cropped to the outermost HTML element or the chosen selector. Adjust viewport and sizing settings below.
?

Take a screenshot of the entire screen

?

Adjusts the screenshot pixel ratio. HTML and template renders default to 2; URL renders default to 1.

?

Set the height and width of Chrome's viewport. Setting a viewport disables automatic cropping.

Sets the emulated viewport orientation to landscape.

Makes the emulated viewport behave like a mobile device and honor mobile viewport behavior.

Makes the emulated viewport report support for touch events.


Timing

By default the API generates a screenshot once everything is loaded. If the page executes JavaScript, you may want extra time before the image is rendered.
?

Adds extra time for JavaScript to execute before the screenshot is taken. Start with 500 milliseconds if the page renders blank.

?

Sets a limit on how long to wait before taking the screenshot when irrelevant content continues loading.

?

Waits for the page to signal that the screenshot is ready instead of capturing after normal loading.


Browser Context

These settings impact how Chrome is started, giving you more control when taking screenshots.
?

Set Chrome to render as if the user prefers light or dark mode.

Set Chrome to render the page using print or screen media styles.

?

Render the page with Chrome set to a specified timezone.

?

Send X-HCTI-SCREENSHOT: 1 with the top-level page navigation.

Preview

Your screenshot will appear here

Enter a URL, choose the settings you need, and generate the image.

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 .webp 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 .webp URL.

  • Public webpage URL

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

  • WebP output

    Set format to webp and use the hosted .webp 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": "webp",
"viewport_width": 1200,
"viewport_height": 630
}

How it works

From webpage URL to a finished WebP

  1. Send the webpage URL

    Submit a public URL with format set to webp 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 .webp URL

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

Example code

Screenshot a webpage as WebP in PHP

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

<?php

$request = [
    "url" => "https://example.com",
    "format" => "webp",
    "viewport_height" => 630,
    "viewport_width" => 1200,
];

$curl = curl_init("https://hcti.io/v1/image");
curl_setopt_array($curl, [
    CURLOPT_POST => true,
    CURLOPT_USERPWD => sprintf("%s:%s", getenv("HCTI_API_ID"), getenv("HCTI_API_KEY")),
    CURLOPT_HTTPHEADER => ["Content-Type: application/json"],
    CURLOPT_POSTFIELDS => json_encode($request, JSON_THROW_ON_ERROR),
    CURLOPT_RETURNTRANSFER => true,
]);

$response = curl_exec($curl);
if ($response === false) {
    throw new RuntimeException(curl_error($curl));
}
$status = curl_getinfo($curl, CURLINFO_RESPONSE_CODE);
curl_close($curl);
if ($status >= 400) {
    throw new RuntimeException(sprintf("HCTI request failed (%d): %s", $status, $response));
}

$result = json_decode($response, true, 512, JSON_THROW_ON_ERROR);
printf("%s\n", $result["url"]);

Ready to capture?

Take your first WebP webpage screenshot

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