PHPackages                             spatie/laravel-og-image - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Image &amp; Media](/categories/media)
4. /
5. spatie/laravel-og-image

ActiveLibrary[Image &amp; Media](/categories/media)

spatie/laravel-og-image
=======================

Generate OG images for your Laravel app

1.3.1(2mo ago)3661.6k↑302.4%31MITPHPPHP ^8.3CI passing

Since Feb 19Pushed 1mo agoCompare

[ Source](https://github.com/spatie/laravel-og-image)[ Packagist](https://packagist.org/packages/spatie/laravel-og-image)[ Docs](https://github.com/spatie/laravel-og-image)[ GitHub Sponsors](https://github.com/Spatie)[ RSS](/packages/spatie-laravel-og-image/feed)WikiDiscussions main Synced 2w ago

READMEChangelog (10)Dependencies (48)Versions (16)Used By (1)

 [   ![Logo for Laravel Open Graph Image](https://camo.githubusercontent.com/8e096ef43f0c4d4bcdb183d8cd70afb6a4f0db7f07c678e5ee2162595e2b6a99/68747470733a2f2f7370617469652e62652f7061636b616765732f6865616465722f6c61726176656c2d6f672d696d6167652f68746d6c2f6c696768742e776562703f313233)  ](https://spatie.be/open-source?utm_source=github&utm_medium=banner&utm_campaign=laravel-og-image)Generate OG images for your Laravel app
=======================================

[](#generate-og-images-for-your-laravel-app)

[![Latest Version on Packagist](https://camo.githubusercontent.com/a7f61fdaf391354075b8041ee064d2ba1388906a1499f67aecc662e0075c384c/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f7370617469652f6c61726176656c2d6f672d696d6167652e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/spatie/laravel-og-image)[![GitHub Tests Action Status](https://github.com/spatie/laravel-og-image/actions/workflows/run-tests.yml/badge.svg)](https://github.com/spatie/laravel-og-image/actions?query=workflow%3Arun-tests+branch%3Amain)[![GitHub Code Style Action Status](https://github.com/spatie/laravel-og-image/actions/workflows/fix-php-code-style-issues.yml/badge.svg)](https://github.com/spatie/laravel-og-image/actions?query=workflow%3A%22Fix+PHP+code+style+issues%22+branch%3Amain)[![Total Downloads](https://camo.githubusercontent.com/c656fb89b04d5f5bdb31547513b8ca1e40467d9941b2cb529a24dbc52b7f4a59/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f7370617469652f6c61726176656c2d6f672d696d6167652e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/spatie/laravel-og-image)

This package makes it easy to generate Open Graph images for your Laravel application. Define your OG image HTML inline in your Blade views, and the package automatically generates screenshot images using [spatie/laravel-screenshot](https://github.com/spatie/laravel-screenshot), serves them via a dedicated route, and caches them on disk.

Your OG image templates inherit your page's existing CSS, fonts, and Vite assets. No separate CSS configuration needed.

No external API needed. Everything runs on your own server.

Support us
----------

[](#support-us)

[![](https://camo.githubusercontent.com/aa0735a4be7a23cc4b502017dea14e9009cd90cafd1b9d85e060d1a4f894d720/68747470733a2f2f6769746875622d6164732e73332e65752d63656e7472616c2d312e616d617a6f6e6177732e636f6d2f6c61726176656c2d6f672d696d6167652e6a70673f743d31)](https://spatie.be/github-ad-click/laravel-og-image)

We invest a lot of resources into creating [best in class open source packages](https://spatie.be/open-source). You can support us by [buying one of our paid products](https://spatie.be/open-source/support-us).

We highly appreciate you sending us a postcard from your hometown, mentioning which of our package(s) you are using. You'll find our address on [our contact page](https://spatie.be/about-us). We publish all received postcards on [our virtual postcard wall](https://spatie.be/open-source/postcards).

Documentation
-------------

[](#documentation)

You'll find full documentation on [our documentation site](https://spatie.be/docs/laravel-og-image).

Basic usage
-----------

[](#basic-usage)

Use the Blade component to define your OG image inline:

```

        {{ $post->title }}

```

This outputs a hidden `` tag and `` tags pointing to a generated screenshot of your HTML at 1200×630 pixels.

How it works
------------

[](#how-it-works)

1. Your HTML is rendered inside a `` tag on the page
2. The page URL is cached, keyed by the md5 hash of the HTML content
3. Meta tags point to `/og-image/{hash}.jpeg`
4. When that URL is first requested, the page is visited with `?ogimage` appended, rendering just the template content with the page's full CSS at 1200×630
5. The generated image is saved to your public disk and served directly with cache headers
6. Subsequent requests serve the image from disk (or CDN cache)

Preview any OG image by appending `?ogimage` to the page URL.

Installation
------------

[](#installation)

You can install the package via composer:

```
composer require spatie/laravel-og-image
```

This package requires [spatie/laravel-screenshot](https://github.com/spatie/laravel-screenshot), which uses Browsershot under the hood. Make sure you have Node.js and a Chrome/Chromium binary installed.

You can optionally publish the config file:

```
php artisan vendor:publish --tag="og-image-config"
```

Testing
-------

[](#testing)

```
composer test
```

Changelog
---------

[](#changelog)

Please see [CHANGELOG](CHANGELOG.md) for more information on what has changed recently.

Contributing
------------

[](#contributing)

Please see [CONTRIBUTING](CONTRIBUTING.md) for details.

Security Vulnerabilities
------------------------

[](#security-vulnerabilities)

Please review [our security policy](../../security/policy) on how to report security vulnerabilities.

Credits
-------

[](#credits)

- [Freek Van der Herten](https://github.com/freekmurze)
- [All Contributors](../../contributors)

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

###  Health Score

55

—

FairBetter than 97% of packages

Maintenance88

Actively maintained with recent releases

Popularity43

Moderate usage in the ecosystem

Community17

Small or concentrated contributor base

Maturity58

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 85.7% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~10 days

Recently: every ~26 days

Total

12

Last Release

63d ago

Major Versions

0.0.3 → 1.0.02026-02-24

PHP version history (2 changes)0.0.1PHP ^8.4

1.0.0PHP ^8.3

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/7535935?v=4)[Spatie](/maintainers/spatie)[@spatie](https://github.com/spatie)

---

Top Contributors

[![freekmurze](https://avatars.githubusercontent.com/u/483853?v=4)](https://github.com/freekmurze "freekmurze (54 commits)")[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (4 commits)")[![jimirobaer](https://avatars.githubusercontent.com/u/8984769?v=4)](https://github.com/jimirobaer "jimirobaer (1 commits)")[![mattiasgeniar](https://avatars.githubusercontent.com/u/407270?v=4)](https://github.com/mattiasgeniar "mattiasgeniar (1 commits)")[![wannevancamp](https://avatars.githubusercontent.com/u/3399877?v=4)](https://github.com/wannevancamp "wannevancamp (1 commits)")[![github-actions[bot]](https://avatars.githubusercontent.com/in/15368?v=4)](https://github.com/github-actions[bot] "github-actions[bot] (1 commits)")[![beblife](https://avatars.githubusercontent.com/u/9271492?v=4)](https://github.com/beblife "beblife (1 commits)")

---

Tags

laravelogimagephpseospatiespatielaravelopen-graphog-imagelaravel-og-image

###  Code Quality

TestsPest

Static AnalysisPHPStan

Code StyleLaravel Pint

### Embed Badge

![Health badge](/badges/spatie-laravel-og-image/health.svg)

```
[![Health](https://phpackages.com/badges/spatie-laravel-og-image/health.svg)](https://phpackages.com/packages/spatie-laravel-og-image)
```

###  Alternatives

[spatie/laravel-health

Monitor the health of a Laravel application

88212.7M188](/packages/spatie-laravel-health)[defstudio/telegraph

A laravel facade to interact with Telegram Bots

818355.4k3](/packages/defstudio-telegraph)[harris21/laravel-fuse

Circuit breaker for Laravel queue jobs. Protect your workers from cascading failures.

46273.9k](/packages/harris21-laravel-fuse)[psalm/plugin-laravel

Psalm plugin for Laravel

3345.4M354](/packages/psalm-plugin-laravel)[simplestats-io/laravel-client

Server-side analytics for Laravel that follows the full funnel from visit to registration to payment, attributed to the channel that drove it. Revenue, MRR, churn and ad-spend profit (ROAS/CAC) per channel. GDPR compliant, ad-blocker proof.

5226.7k](/packages/simplestats-io-laravel-client)[rawilk/profile-filament-plugin

Profile &amp; MFA starter kit for filament.

3915.5k](/packages/rawilk-profile-filament-plugin)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
