Posts Learn Components Snippets Categories Tags Tools About
/

How to Save Screenshot from Browsershot

Get to know how to Save Screenshot from Browsershot package by spatie and then save it to S3 Disk or any of the disk you are currently using

Created on Jan 25, 2022

497 views

To save a screenshot from the Browsershot package that's other than the local file you can call the "screenshot()" method at the end which then will return the file that can be saved into a disk such as "s3" or other object storage such as "vultr" and "digital ocean".
<?php

use Illuminate\Support\Facades\Storage;

$screenshot = Browsershot::url('url-to-screenshot')
            ->setScreenshotType('png')
            ->fullPage()
            ->setOption('viewport.deviceScaleFactor', 1)
            ->setDelay(3000)
            ->screenshot();

Storage::disk('s3')->put('image.png', $screenshot, 'public');
By doing so you can specify any of the other disk types other than saving it to the storage directory. Do give it a try first and cheers! Happy coding.

If you like our tutorial, do make sure to support us by being our Patreon or buy us some coffee ☕️

Load comments for How to Save Screenshot from Browsershot

)