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.
#1 Best Overall
| 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.
Rank #2
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.
Recommended Free Tools
- 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
-1disables 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.
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.
Rank #4
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.
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.
Quick Recap
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.




