Hardware FixRecommendedDevice not working? Your driver may be the problemCheck updates for common hardware issues.Fix DriversOctober DealsAmazon USOctober deal check: compare before you payAmazon US: current deals, useful picks and tech finds.Check DealsPC HealthRecommendedCrashes, freezes, slowdowns? Check your PC nowSpot repairable issues before they interrupt work.Check PC×
Skip to content
World desk5 min

GrabzIt Screenshot API Examples for PHP

Capture websites, HTML strings, and local files with GrabzIt’s PHP screenshot API, with examples explaining image options and callback-based Save versus local SaveTo.
Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

To capture a webpage with GrabzIt’s PHP library, create a GrabzItClient using your application key and secret, call URLToImage(), then save the result. Use SaveTo() for a local file—including on localhost—or Save() when you have a publicly reachable handler URL to process the completed capture. The examples below cover URLs, HTML, local files, image options, and the difference between the two saving methods.

Basic PHP website screenshot

Include the GrabzIt PHP client library, initialize it with the credentials for your application, request an image capture, and save the result. Replace the credential placeholders with your own values; do not publish real application credentials.

<?php
include 'GrabzItClient.php';

$grabzIt = new \GrabzIt\GrabzItClient('APPLICATION KEY', 'APPLICATION SECRET');
$grabzIt->URLToImage('https://example.com');
$grabzIt->SaveTo(__DIR__ . '/result.jpg');

This example uses the URL input method and saves the image to a local path. GrabzIt’s PHP flow requires a saving step after the capture request. See the GrabzIt PHP library overview and the image capture options reference for the documented API details.

Choose the input method

Use the method that matches what you need to render: a public webpage URL, an HTML string, or a local HTML file.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Input Method Typical use
Webpage URL URLToImage($url) Capture a page available at a URL.
HTML string HTMLToImage($html) Render markup supplied by your PHP application.
Local file FileToImage($path) Capture an HTML file on disk.

Each method is followed by either Save() or SaveTo(). The vendor overview also documents corresponding URLToPDF(), HTMLToPDF(), and FileToPDF() methods for PDF output.

Capture HTML supplied by PHP

<?php
include 'GrabzItClient.php';

$grabzIt = new \GrabzIt\GrabzItClient('APPLICATION KEY', 'APPLICATION SECRET');
$html = '<html><body><h1>Status report</h1><p>Generated by PHP</p></body></html>';
$grabzIt->HTMLToImage($html);
$grabzIt->SaveTo(__DIR__ . '/status-report.jpg');

Capture a local HTML file

<?php
include 'GrabzItClient.php';

$grabzIt = new \GrabzIt\GrabzItClient('APPLICATION KEY', 'APPLICATION SECRET');
$grabzIt->FileToImage(__DIR__ . '/report.html');
$grabzIt->SaveTo(__DIR__ . '/report.jpg');

Save() versus SaveTo()

Method Completion flow Use it when
Save($handlerUrl) Uses a handler URL to process the completed capture. Your application has a publicly accessible callback handler.
SaveTo($path) Waits synchronously for the capture and saves the result to the requested file path. You need a local output path, or do not have a publicly reachable callback handler. GrabzIt specifically recommends this for localhost.

For a deployment with a reachable handler, the documented pattern is:

<?php
include 'GrabzItClient.php';

$grabzIt = new \GrabzIt\GrabzItClient('APPLICATION KEY', 'APPLICATION SECRET');
$grabzIt->URLToImage('https://example.com');
$grabzIt->Save('https://your-domain.example/handler.php');

The handler is part of the callback workflow: it processes the capture after completion. If you are running locally and cannot expose a handler publicly, use SaveTo() instead. Setup guidance is available in GrabzIt’s demo setup instructions.

Set image options for the capture

GrabzIt’s image options include output format, image dimensions, browser dimensions, delay, and CSS-selector controls. The option reference demonstrates configuring options after requesting a capture; confirm the exact method signatures against the library version you use.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
  • Format: JPG is the documented default. PNG is also available, and GrabzIt recommends PNG for screenshots when JPG quality may be insufficient; that is vendor guidance, not an independent image-quality comparison.
  • Dimensions: Set width and height for a fixed output. A dimension of -1 disables cropping for that dimension. Full-page uncropped captures can be large, and the reference notes that there is no full-length browser width.
  • Element capture: Use a CSS selector to target an element, for example #features. If several elements match, the first match is used.
  • Dynamic pages: Delay and wait-for-element settings are available, but they cannot guarantee that every site has finished rendering all content.

The full option set includes target, hide, wait-for, click, hover, and scroll behavior. Use the image options guide and PHP technical documentation for the relevant option names and signatures.

Or skip the browser setup

If you want a direct screenshot request rather than managing a browser-capture integration, ScreenshotNeo is a website screenshot API and MCP server. One GET request can return an image or PDF. Here is the cURL version; replace the target URL and API key:

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 the request parameters and additional examples. Cookie banners are accepted and removed before capture, along with known newsletter popups and chat widgets; those steps can be turned off. Bot checks or CAPTCHAs, blank pages, timeouts, failed loads, and cache hits are not billed, and response headers identify the page verdict and billing status. Its MCP server provides take_screenshot, get_page_info, and capture_pdf for AI agents. The Free plan includes 1,000 screenshots per month without a card; paid plans start at $5 for 3,000 shots.

Sign up for ScreenshotNeo’s free plan: 1,000 screenshots a month, no card required.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Troubleshooting

The script cannot find GrabzItClient.php

PHP must be able to load the client library at the path used by include. Check where the library is installed and update the include path or use the correct relative path for your application.

The capture does not arrive at the handler

Save() depends on a handler URL that can be reached publicly and can process the completed capture. If you are testing on localhost or do not have a reachable callback, switch to SaveTo() and provide a writable local file path.

The output file is missing

Check that the destination directory exists and is writable by the PHP process. With SaveTo(), the capture and save happen synchronously, so the application waits for the result rather than relying on a later callback.

The image is cropped or unexpectedly large

Review the requested width and height. Fixed dimensions crop output; -1 disables cropping on that axis, which can create a very large full-page image. There is no full-length browser width, so set a practical browser width as well as deciding whether the page should be cropped vertically.

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

A dynamic page is captured before it looks complete

Use the documented delay or wait-for-element options to allow expected content to appear. These controls address timing but do not guarantee that every asynchronous feature on a site has finished loading.

PHP compatibility and version notes

The cited GrabzIt PHP pages document the API flow and options but do not establish a current PHP compatibility range or the latest library release. Check the current package and technical documentation for the version you install rather than assuming compatibility with a particular PHP version.

Frequently Asked Questions

Can GrabzIt capture a single element instead of the entire page?

Yes. Its PHP image options include CSS-selector targeting; if multiple elements match, the first matching element is used.

Does the PHP API support PDF output too?

The PHP overview documents URL, HTML, and file input methods for PDF capture as well as image capture.

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

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.

Leave a Reply

Your email address will not be published. Required fields are marked *

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.

More from the Wire

  1. Shenzhen desk3 min
    HONOR Expands Beyond Smartphones With Humanoid Robot RevealHONOR said it unveiled its first humanoid robot at MWC 2026 and named shopping assistance, workplace inspections, and supportive companionship as intended uses. Later Robotics D1 claims and a reported…
  2. Cupertino desk5 min
    Apple Unveils AirPods Max 2: The Upgrade That Should Have Happened Years AgoAirPods Max 2 adds H2-powered audio features and Apple claims up to 1.5× more effective ANC, but its design, Smart Case, and 20-hour battery rating are unchanged. Wired lossless audio…
  3. Cupertino desk4 min
    Apple’s OLED Touch MacBooks Are Coming—but the Dynamic Island Is the Real GambleApple has not announced an OLED touchscreen MacBook, but reports point to high-end models arriving in late 2026 or early 2027. The reported Mac Dynamic Island could be useful, but…
Recommended PC Tool
Recommended PC Tool
Outdated Drivers Are Slowing You DownFree scan - exact matches
Windows Errors? Fix Them Before They SpreadFree repair scan

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.