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.0(2mo ago)305.2k—2.2%2[2 PRs](https://github.com/spatie/laravel-og-image/pulls)MITPHPPHP ^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 1mo ago

READMEChangelog (6)Dependencies (32)Versions (13)Used By (0)

 [   ![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://camo.githubusercontent.com/26e7cbe413d49fe40c0497eaa518bea1a436782c8d6df14fa3eadab76d207eba/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f7370617469652f6c61726176656c2d6f672d696d6167652f72756e2d74657374732e796d6c3f6272616e63683d6d61696e266c6162656c3d7465737473267374796c653d666c61742d737175617265)](https://github.com/spatie/laravel-og-image/actions?query=workflow%3Arun-tests+branch%3Amain)[![GitHub Code Style Action Status](https://camo.githubusercontent.com/b766e7c47fb0e88f450b92f32dbbbb25d66f1df10a0044702fb10a567275f30a/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f7370617469652f6c61726176656c2d6f672d696d6167652f6669782d7068702d636f64652d7374796c652d6973737565732e796d6c3f6272616e63683d6d61696e266c6162656c3d636f64652532307374796c65267374796c653d666c61742d737175617265)](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

52

—

FairBetter than 96% of packages

Maintenance89

Actively maintained with recent releases

Popularity36

Limited adoption so far

Community12

Small or concentrated contributor base

Maturity56

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 94% 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 ~3 days

Total

9

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 (47 commits)")[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (1 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)")

---

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

86910.0M83](/packages/spatie-laravel-health)[spatie/laravel-livewire-wizard

Build wizards using Livewire

4061.0M4](/packages/spatie-laravel-livewire-wizard)[spatie/laravel-prometheus

Export Laravel metrics to Prometheus

2651.3M6](/packages/spatie-laravel-prometheus)[vormkracht10/laravel-open-graph-image

Laravel package to generate dynamic Open Graph images

7217.7k](/packages/vormkracht10-laravel-open-graph-image)[ralphjsmit/laravel-glide

Auto-magically generate responsive images from static image files.

4719.6k5](/packages/ralphjsmit-laravel-glide)[saasykit/laravel-open-graphy

An awesome open graph image (social cards) generator package for Laravel.

13057.0k](/packages/saasykit-laravel-open-graphy)

PHPackages © 2026

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