October DealsAmazon USOctober deal check: compare before you payAmazon US: current deals, useful picks and tech finds.Check DealsSlow PC?RecommendedPC slow today? Run a repair scan before it gets worseResolve common Windows issues and optimize system performance.Scan NowOctober DealsAmazon USDeal season is back - check today's better picksAmazon US: current deals, useful picks and tech finds.See Picks×
Skip to content
World desk6 min

Use Laravel Browsershot to Generate Website Screenshot Thumbnails in a Queue

Move website screenshot generation out of the request cycle with a Laravel queued job that runs Browsershot on a properly configured worker.
Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

To generate website screenshot thumbnails without holding up a normal web request, dispatch a Laravel queued job and call Spatie Browsershot from the job’s handle() method. The queue worker must have access to Node.js, Puppeteer, and Chrome or Chromium, and the job should write to a path or storage location that your application can use after capture.

Generate a screenshot in a Laravel queued job

This direct approach combines Laravel’s queued-job pattern with Browsershot’s URL-to-image API. It is an API-based implementation example, not a tested recipe; adjust storage, validation, and job settings for your application. The queue documentation cited here is for Laravel 12.x and is marked as an old documentation version, so use the documentation matching your installed release.

As an Amazon Associate I earn from qualifying purchases.

1. Create the job

For example, create a job with php artisan make:job GenerateScreenshot, then implement it along these lines:

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

namespace AppJobs;

use IlluminateContractsQueueShouldQueue;
use SpatieBrowsershotBrowsershot;

class GenerateScreenshot implements ShouldQueue
{
    public function __construct(
        public string $url,
        public string $path,
    ) {}

    public function handle(): void
    {
        Browsershot::url($this->url)->save($this->path);
    }
}

Browsershot::url($url)->save($path) asks Browsershot to render the URL and save an image at the given path. In a production application, validate or constrain the URL and determine how the destination path maps to storage that your app can access. Avoid treating an arbitrary user-submitted URL as trusted input.

2. Dispatch the job

Dispatch it from the controller or service that initiates thumbnail generation. Keep the job payload to serializable values such as the URL and destination path:

use AppJobsGenerateScreenshot;

GenerateScreenshot::dispatch(
    'https://example.com',
    storage_path('app/screenshots/example.png'),
)->onQueue('screenshots');

The onQueue() call is optional. Use a named queue when you want screenshot work separated from other queued work. Configure the queue connection in Laravel’s normal queue configuration.

3. Run a worker for that queue

Start a worker that listens to the selected queue; for example:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Rank #2
Free Fling File Transfer Software for Windows [PC Download]
  • Intuitive interface of a conventional FTP client
  • Easy and Reliable FTP Site Maintenance.
  • FTP Automation and Synchronization
php artisan queue:work --queue=screenshots

A dispatched job will not run until a worker is processing its connection and queue. In deployment, supervise the worker process and make sure its environment, filesystem permissions, and browser dependencies match the application’s requirements.

Make the output usable after the job finishes

The example writes to a local path. That is suitable only when the worker and the application can both access the same filesystem. If workers run in separate containers or hosts, local output may not be available to the web process after the job ends. Choose an output strategy deliberately:

  • Shared local storage: write to a shared, persistent location and retain a relative path or other durable reference in your application.
  • Object storage: write or upload the completed image to the storage configured for your application, then store its key or URL as appropriate.
  • Completion state: record whether capture succeeded and expose the resulting image only after the job completes successfully.

For reliable application behavior, handle job failure through Laravel’s job failure and retry mechanisms or your own application-level reporting. Do not assume that dispatching the job means the screenshot already exists; the work is asynchronous.

Choose direct Browsershot or Spatie’s queued screenshot wrapper

Use a custom job when you want to control the job’s payload, storage workflow, and Laravel worker behavior. Spatie’s Laravel Screenshot v1 is an alternative with a queued facade and documented disk, queue/connection, and success/failure callback support.

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

Queued wrapper example

Screenshot::url($url)->saveQueued('screenshots/homepage.png');

Use the wrapper’s documented configuration for selecting a queue, connection, disk, or callbacks. Its saveQueued() API cannot be combined with withBrowsershot(): the customization closure cannot be serialized for the queued operation. If you need per-capture Browsershot customization through that closure, use a different supported flow, such as a custom Laravel job that invokes Browsershot directly.

Prepare the worker’s browser runtime

Browsershot controls headless Google Chrome through Puppeteer. A working development machine does not guarantee a working queue worker: the worker’s own runtime must be able to find and execute the required components.

  • Install compatible Node.js, Puppeteer, and Chrome or Chromium dependencies for the Browsershot version in use.
  • Confirm that the worker’s user or container can access the browser executable, temporary directories, and output destination.
  • If you configure executable or path settings, verify those paths inside the worker environment, not just on the web server.
  • Check that the installed Laravel, Browsershot, and Laravel Screenshot versions are compatible with one another.

The Laravel Screenshot v1 Browsershot driver documentation exposes executable and path configuration, along with a no_sandbox option for restricted environments. Disabling the browser sandbox is a deployment-specific security decision; do not enable it as a generic troubleshooting shortcut.

Set queue behavior for screenshot work

Screenshot rendering can take longer than ordinary short jobs. Spatie’s official Laravel Screenshot documentation notes that “Screenshot generation can be slow, especially with the Browsershot or Cloudflare driver.” Set worker timeouts and retry behavior according to the pages you capture and the resources available to your workers; there is no universal safe timeout for every site and runtime.

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.
  • Use a dedicated queue if browser jobs should not delay unrelated work.
  • Align the job’s timeout and the worker’s timeout/retry configuration with the maximum render time you intend to permit.
  • Decide how failed jobs are surfaced, retried, or marked in your application, so users do not wait indefinitely for a thumbnail.
  • Monitor worker logs and failed jobs, and keep the browser runtime consistent across the processes that consume the queue.

Troubleshoot common failures

Symptom Likely cause What to check
The job stays queued and no image appears. No worker is consuming the configured connection or queue, or the worker is listening to a different queue. Check the queue connection, worker process, and queue name. Start a worker for the queue used by the dispatched job.
The job fails because a browser or executable cannot be found. Node.js, Puppeteer, Chrome/Chromium, or a configured executable path is missing from the worker environment. Check dependencies and configured paths as the worker’s user and inside its container or host.
The worker reports permission or file errors. The worker cannot write to the destination or its temporary directory. Verify directory existence and permissions for the worker user. Use a persistent or shared destination when the output must outlive that worker.
The capture exceeds the job’s allowed runtime. The page or browser startup takes longer than the configured timeout, or worker resources are constrained. Inspect worker and job timeout/retry settings, browser startup, and the target page. Choose limits based on your workload rather than copying a universal number.
saveQueued() cannot use the desired Browsershot closure. The queued wrapper cannot serialize the withBrowsershot() customization closure. Use only the wrapper’s queue-compatible options, or use a custom queued job that calls Browsershot directly.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Or skip the browser setup

If you do not want to install and maintain a local headless-browser runtime, ScreenshotNeo provides a screenshot API and MCP server. A single GET request can return an image or PDF; the example below saves the response body as a WebP file. See the ScreenshotNeo API documentation for request options.

curl -G "https://api.screenshotneo.com/v1/shot" 
  -d access_key=YOUR_API_KEY 
  --data-urlencode url=https://example.com 
  -o shot.webp

ScreenshotNeo removes cookie and consent banners, newsletter popups, and chat widgets before capture; those steps can be turned off. Bot checks/CAPTCHAs, blank pages, timeouts, failed loads, and cache hits are not billed, and response headers report the page verdict and billing status. Its MCP server offers take_screenshot, get_page_info, and capture_pdf for AI agents. The free plan includes 1,000 screenshots per month with no card; paid plans start at $5 for 3,000 shots.

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

Consider a hosted browser when local deployment is not practical

Cloudflare Browser Run is another hosted-browser option; its documentation describes screenshot quick actions and browser sessions. Cloudflare’s product documentation used the name Browser Run as of its 2026-08-11 update, and availability or naming may change. It is a hosted browser integration, not an identical drop-in replacement for a local Browsershot job. The available documentation does not establish a performance or cost winner against local rendering.

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

Frequently Asked Questions

Does dispatching a screenshot job return the image?

No. Dispatch adds work to the queue; a worker must process the job before the output is ready.

Can I use a custom Browsershot closure with Laravel Screenshot’s queued API?

No. The documented `saveQueued()` flow cannot be combined with `withBrowsershot()` because the closure cannot be serialized.

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 *

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

More from the Wire

  1. World desk4 min
    How to Spot an AI Voice Scam Before Sending MoneyDon’t rely on how a caller sounds. Pause, call back through a known number, and verify the emergency with another trusted person before sending money.
  2. Mountain View desk4 min
    Google’s SynthID Detector: How to Check AI-Generated Images, Video and AudioGoogle’s SynthID Detector looks for an embedded watermark in supported images, video and audio. Here is what its results do—and do not—show.
  3. Redmond desk20 min
    How to create a link to File or Folder in Windows 11Windows 11 gives you several ways to point to a file or folder without moving or duplicating it. You can create a desktop shortcut,…
Recommended PC Tool
Recommended PC Tool
PC Slower Than It Used to Be?Free scan - under a minute
Crashes, No Sound, or Screen Glitches?Free driver 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.