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.
davejamesmiller/laravel-breadcrumbs
artisanry/parsedown
christhompsontldr/phpsdk
enqueue/dsn
bunny/bunny
enqueue/test
enqueue/null
enqueue/amqp-tools
milesj/emojibase
bower-asset/punycode
bower-asset/inputmask
bower-asset/jquery
bower-asset/yii2-pjax
laravel/nova
spatie/laravel-mailcoach
spatie/laravel-superseeder
laravel/liferaft
nst/json-test-suite
danielmiessler/sec-lists
jackalope/jackalope-transport