PHPackages                             abordage/laravel-og-images - 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. abordage/laravel-og-images

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

abordage/laravel-og-images
==========================

Generate Open Graph images (og:image, twitter:image, vk:image) for each site pages

1.1.0(3w ago)122.8k[1 PRs](https://github.com/abordage/laravel-og-images/pulls)MITPHPPHP ^8.2CI passing

Since May 26Pushed 1mo ago1 watchersCompare

[ Source](https://github.com/abordage/laravel-og-images)[ Packagist](https://packagist.org/packages/abordage/laravel-og-images)[ Docs](https://github.com/abordage/laravel-og-images)[ RSS](/packages/abordage-laravel-og-images/feed)WikiDiscussions master Synced 3d ago

READMEChangelog (10)Dependencies (16)Versions (15)Used By (0)

Open Graph Image Generator for Laravel
======================================

[](#open-graph-image-generator-for-laravel)

Create Open Graph images (og:image, twitter:image, vk:image) for each (or some) site pages.

[ ![Open Graph Images Generator](https://github.com/abordage/laravel-og-images/raw/master/docs/images/default-og-image-830x435.png?raw=true)](https://github.com/abordage/laravel-og-images/blob/master/docs/examples.md "Open Graph Images Generator")

[ ![Packagist Version](https://camo.githubusercontent.com/b4e168084bca5555abe1f2f7d446499e7297fa6059b8d3693ca347f9c5bbf270/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f61626f72646167652f6c61726176656c2d6f672d696d61676573)](https://packagist.org/packages/abordage/laravel-og-images "Packagist version")[ ![GitHub Tests Status](https://camo.githubusercontent.com/e118228cf1e06f1f59b06a0a68446c7c21767fafd510314512295de4424ee3e4/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f61626f72646167652f6c61726176656c2d6f672d696d616765732f74657374732e796d6c3f6c6162656c3d7465737473)](https://github.com/abordage/laravel-og-images/actions/workflows/tests.yml "GitHub Tests Status")[ ![GitHub Code Style Status](https://camo.githubusercontent.com/919a5d4e5c0eb386d9a59aba55d90a66509ee39053592ef0ad59b4a8254ba18e/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f61626f72646167652f6c61726176656c2d6f672d696d616765732f7068702d63732d66697865722e796d6c3f6c6162656c3d636f64652532307374796c65)](https://github.com/abordage/laravel-og-images/actions/workflows/php-cs-fixer.yml "GitHub Code Style Status")[ ![Packagist PHP Version Support](https://camo.githubusercontent.com/ec0d1538b6b4a67f359f451ad856d14fb5c26846f6036d9d11bd88b0418d8198/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f7068702d762f61626f72646167652f6c61726176656c2d6f672d696d61676573)](https://www.php.net/ "PHP version")[ ![License](https://camo.githubusercontent.com/e103a44bcf9618cefe2ca6819213cfaef1e50ce7576d6c6e6cfbd110f078c9fd/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c6963656e73652f61626f72646167652f6c61726176656c2d6f672d696d61676573)](https://github.com/abordage/laravel-og-images/blob/master/LICENSE.md "License")

Use page title to create an eye-catching page preview when users share the link on social networks or instant messengers. [Learn more](https://ogp.me) about Open Graph.

Features:
---------

[](#features)

- Image generation with your text and site name
- Fully customizable (see [configuration](#configuration))
- Small image size (15-50 Kb) with high resolution and quality ([check it](./docs/examples.md))
- Aspect ratios [presets](#images-aspect-ratios) for popular social networks

[▶ **See examples**](./docs/examples.md)

Requirements
------------

[](#requirements)

- PHP 8.2+
- Laravel 11.x / 12.x
- The Imagick PHP extension

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

[](#installation)

You can install the package via composer:

```
composer require abordage/laravel-og-images
```

You can publish config file with:

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

Quick start
-----------

[](#quick-start)

```
use Abordage\LaravelOpenGraphImages\Facades\OpenGraphImages;

$text = 'The adventures first, explanations take such a dreadful time!';
$path = \Storage::put('first-og-image.png');

$opengraph = OpenGraphImages::make($text)->save($path);
```

> **Note**
> All images are encoded in `PNG` format as it provides the best ratio between size/quality. For the same reason, the package uses the `Imagick` driver - in tests, it showed an advantage in speed and final size of the generated images.

Usage
-----

[](#usage)

```
// for
OpenGraphImages::make($text)->save($path);
// or
OpenGraphImages::make($text, 'opengraph')->save($path);

// for
OpenGraphImages::make($text, 'twitter')->save($path);

// for
OpenGraphImages::make($text, 'vk')->save($path);

// custom size
OpenGraphImages::makeCustom($text, 600, 400)->save($path);
```

After generation, you need to somehow organize the relationship of images with a specific page (for example, attach to a model). If you already have a solution ready to accept an image and attach it to a specific page, you can get the image as a string instead of saving it:

```
$imageBlob = OpenGraphImages::make($text)->get();
```

If after generation you need to get sizes of the image, you can get it as follows:

```
$openGraphImage = OpenGraphImages::make($text, 'twitter');
$openGraphImage->save($path);
$imageSizes = $openGraphImage->getImageSizes();
// return [
//    'width' => 1200,
//    'height' => 600
// ];
```

Usage with `spatie/laravel-medialibrary`
----------------------------------------

[](#usage-with-spatielaravel-medialibrary)

[spatie/laravel-medialibrary](https://github.com/spatie/laravel-medialibrary) is a great package for associate all sorts of files with Eloquent models. If you are using this package (or similar), all you need to do is to add new collections to the model and attach images using media library.

```
class Page extends Model implements HasMedia
{
    use InteractsWithMedia;

    // ...

    public function registerMediaCollections(): void
    {
        // ...

        $this->addMediaCollection('opengraph')
             ->singleFile();

        $this->addMediaCollection('twitter')
             ->singleFile();
    }

    // ...
}
```

Next, when creating a new page (or updating), generate an og-image and attach it:

```
$page = new Page();
$page->title = 'Your awesome title';
$page->save();

// generate image and attach to model
$image = OpenGraphImages::make($page->title);
$page->addMediaFromString($image->get())
     ->usingFileName(\Str::slug($page->title) . '.png')
     ->withCustomProperties($image->getImageSizes())
     ->toMediaCollection('opengraph');
```

Multiple images:

```
$page = new Page();
$page->title = 'Your awesome title';
$page->save();

$presets = ['opengraph', 'twitter', 'vk'];
foreach ($presets as $preset) {
    $image = OpenGraphImages::make($page->title, $preset);
    $page->addMediaFromString($image->get())
         ->usingFileName(\Str::slug($page->title) . '-' . $preset . '.png')
         ->withCustomProperties($image->getImageSizes())
         ->toMediaCollection($preset);
}
```

Now you can get the link for the og:image meta tag as follows:

```
$ogImageUrl = $page->getFirstMediaUrl('opengraph');
$twitterImageUrl = $page->getFirstMediaUrl('twitter');
$vkImageUrl = $page->getFirstMediaUrl('vk');
```

Configuration
-------------

[](#configuration)

```
$config = [
    /*
    |--------------------------------------------------------------------------
    | Background Color
    |--------------------------------------------------------------------------
    |
    | Supported: HEX, RGB or RGBA format
    |
    */
    'background_color' => '#474761',

    /*
    |--------------------------------------------------------------------------
    | Text Color
    |--------------------------------------------------------------------------
    |
    | Supported: HEX, RGB or RGBA format
    |
    */
    'text_color' => '#eee',

    /*
    |--------------------------------------------------------------------------
    | App Name
    |--------------------------------------------------------------------------
    |
    | Set null to disable
    |
    | Supported: string or null
    |
    */
    'app_name' => config('app.name'),

    /*
    |--------------------------------------------------------------------------
    | App Name Text Color
    |--------------------------------------------------------------------------
    |
    | Supported: HEX, RGB or RGBA format
    |
    */
    'app_name_color' => '#eee',

    /*
    |--------------------------------------------------------------------------
    | App Name Decoration Color
    |--------------------------------------------------------------------------
    |
    | Supported: HEX, RGB or RGBA format
    |
    */
    'app_name_decoration_color' => '#fb3361',

    /*
    |--------------------------------------------------------------------------
    | Text Alignment
    |--------------------------------------------------------------------------
    |
    | Multiline text alignment
    |
    | Supported: "left", "center", "right"
    |
    */
    'text_alignment' => 'left',

    /*
    |--------------------------------------------------------------------------
    | Text Sticky
    |--------------------------------------------------------------------------
    |
    | Supported: "left", "center", "right"
    |
    */
    'text_sticky' => 'center',

    /*
    |--------------------------------------------------------------------------
    | App Name Position
    |--------------------------------------------------------------------------
    |
    | Supported: "top-left", "top-center", "top-right",
    |            "bottom-left", "bottom-center", "bottom-right"
    |
    */
    'app_name_position' => 'bottom-center',

    /*
    |--------------------------------------------------------------------------
    | App Name Decoration Style
    |--------------------------------------------------------------------------
    |
    | Set null to disable
    |
    | Supported: "line", "label", "rectangle", null
    |
    */
    'app_name_decoration_style' => 'line',

    /*
    |--------------------------------------------------------------------------
    | Font Size
    |--------------------------------------------------------------------------
    |
    */
    'font_size' => 55,

    /*
    |--------------------------------------------------------------------------
    | App Name Font Size
    |--------------------------------------------------------------------------
    |
    */
    'app_name_font_size' => 30,

    /*
    |--------------------------------------------------------------------------
    | Text Font
    |--------------------------------------------------------------------------
    |
    | If set null, will be used Preset Font (Roboto Regular)
    |
    | Supported: "absolute/path/to/your/font.ttf", null
    |
    */
    'font_path' => null,

    /*
    |--------------------------------------------------------------------------
    | App Name Font
    |--------------------------------------------------------------------------
    |
    | If set null, will be used Preset Font (Roboto Medium)
    |
    | Supported: "absolute/path/to/your/font.ttf", null
    |
    */
    'app_name_font_path' => null,
];
```

API Reference
-------------

[](#api-reference)

MethodReturnsAdded inChanged in`make(string $text, string $preset = 'opengraph')`self0.1.00.2.0`makeCustom(string $text, int $width, int $height)`self0.2.0-`get()`string0.1.0-`save(string $path)`boolean0.1.0-`getImageSizes()`array0.3.0-### Images aspect ratios

[](#images-aspect-ratios)

PresetAspect ratiosDocs`make(string $text)`1200 x 630 (1.91:1)`make(string $text, 'opengraph')`1200 x 630 (1.91:1)`make(string $text, 'facebook')`1200 x 630 (1.91:1)[fb](https://developers.facebook.com/docs/sharing/webmasters/images/)`make(string $text, 'twitter')`1200 x 600 (2:1)[twitter](https://developer.twitter.com/en/docs/twitter-for-websites/cards/overview/summary-card-with-large-image)`make(string $text, 'vk')`1200 x 536 (2.2:1)[vk](https://dev.vk.com/api/posts)Roadmap
-------

[](#roadmap)

Add ability to use gradients and images for the background.

Testing
-------

[](#testing)

Run all tests

```
composer test:all
```

or

```
composer test:phpunit
composer test:phpstan
composer test:phpcs
```

or see

Feedback
--------

[](#feedback)

Find a bug or have a feature request? Open an issue, or better yet, submit a pull request - contribution welcome!

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

[](#contributing)

Please see [CONTRIBUTING](https://github.com/abordage/.github/blob/master/CONTRIBUTING.md) for details.

Credits
-------

[](#credits)

- Pavel Bychko ([abordage](https://github.com/abordage))
- [All Contributors](https://github.com/abordage/laravel-og-images/graphs/contributors)

License
-------

[](#license)

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

###  Health Score

53

—

FairBetter than 97% of packages

Maintenance92

Actively maintained with recent releases

Popularity26

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity68

Established project with proven stability

 Bus Factor1

Top contributor holds 59.6% 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 ~129 days

Recently: every ~288 days

Total

12

Last Release

21d ago

Major Versions

0.4.2 → 1.0.02025-12-27

PHP version history (2 changes)0.1.0PHP &gt;=7.4

1.0.0PHP ^8.2

### Community

Maintainers

![](https://www.gravatar.com/avatar/c87a6833167a0a9698e160af28d0c4bbc1813a672ca5dc8a83fbc5cdd7714e06?d=identicon)[abordage](/maintainers/abordage)

---

Top Contributors

[![abordage](https://avatars.githubusercontent.com/u/28537731?v=4)](https://github.com/abordage "abordage (65 commits)")[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (26 commits)")[![github-actions[bot]](https://avatars.githubusercontent.com/in/15368?v=4)](https://github.com/github-actions[bot] "github-actions[bot] (18 commits)")

---

Tags

laravel-opengraphog-imageslaravel 11laravel 12opengraphopen-graphog-imagetwitter imagevk imagelaravel-og-images

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Code StylePHP CS Fixer

### Embed Badge

![Health badge](/badges/abordage-laravel-og-images/health.svg)

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

###  Alternatives

[aws/aws-sdk-php-laravel

A simple Laravel 9/10/11/12/13 service provider for including the AWS SDK for PHP.

1.7k35.6M75](/packages/aws-aws-sdk-php-laravel)[essence/essence

Extracts information about medias on the web, like youtube videos, twitter statuses or blog articles.

770562.9k3](/packages/essence-essence)[spatie/laravel-og-image

Generate OG images for your Laravel app

305.2k](/packages/spatie-laravel-og-image)[vormkracht10/laravel-open-graph-image

Laravel package to generate dynamic Open Graph images

7217.7k](/packages/vormkracht10-laravel-open-graph-image)[itsmurumba/laravel-mpesa

Laravel Package for Mpesa Daraja API

191.6k](/packages/itsmurumba-laravel-mpesa)

PHPackages © 2026

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