By default, the package uses Browsershot (headless Chrome) to take screenshots. You can also use Cloudflare's Browser Rendering by calling useCloudflare(). See customizing screenshots for details.
If neither of these fits your needs, you can create your own screenshot driver.
##Creating a driver
A custom driver must implement the ScreenshotDriver interface from spatie/laravel-screenshot:
use Spatie\LaravelScreenshot\Drivers\ScreenshotDriver;
use Spatie\LaravelScreenshot\ScreenshotOptions;
class MyScreenshotDriver implements ScreenshotDriver
{
public function generateScreenshot(
string $input,
bool $isHtml,
ScreenshotOptions $options,
): string {
}
public function saveScreenshot(
string $input,
bool $isHtml,
ScreenshotOptions $options,
string $path,
): void {
}
}
The ScreenshotOptions object gives you access to all configured options like $options->width, $options->height, $options->type (an ImageType enum), $options->deviceScaleFactor, and more.
##Registering the driver
use Spatie\OgImage\Facades\OgImage;
OgImage::useDriver(new MyScreenshotDriver());