Weave Code
Code Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Laravel Og Image Laravel Package

spatie/laravel-og-image

Generate Open Graph images in Laravel from Blade-defined HTML. Automatically renders screenshots, serves them from a route, and caches files. Templates reuse your app’s CSS, fonts, and Vite assets—no external API required.

View on GitHub
Deep Wiki
Context7

title: Using a custom screenshot driver weight: 4

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 {
        // Take the screenshot and return the image as a binary string.
        //
        // $input is a URL (when $isHtml is false) or an HTML string (when $isHtml is true).
        // $options contains width, height, type, deviceScaleFactor, etc.
    }

    public function saveScreenshot(
        string $input,
        bool $isHtml,
        ScreenshotOptions $options,
        string $path,
    ): void {
        // Take the screenshot and save it to $path.
    }
}

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());
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
hexters/coinpayment
rjcodes/rjcms
act-training/laravel-permissions-manager
alimarchal/laravel-chart-of-accounts
babenkoivan/elastic-scout-driver
mkwebdesign/filament-watchdog-v5
renatomarinho/laravel-page-speed
zedmagdy/filament-business-hours
renatovdemoura/blade-elements-ui
devgeek/beacon-admin
benjamin-rqt/data-watcher-bundle
atriumphp/atrium
sandermuller/package-boost-laravel
sandermuller/boost-skills
redaxo/core
yusufgenc/filament-api-forge
l3aro/rating-star-for-filament
leek/filament-subtenant-scope
anil/file-picker
broqit/fields-ai