Home / Snippets / How to Save Screenshot from Browsershot
How to Save Screenshot from Browsershot cover

How to Save Screenshot from Browsershot

516

2 years ago

0 comments

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.
notion avatar

Alaz

Week-end developer currently experimenting with web, mobile, and all things programming.

Topics:

Frontend

Resource

Average

Average

Support Us

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

Welcome to PostSrc V3

PostSrc Dark Logo

You have to login to favorite this