Download the PHP package abordage/og-images without Composer
On this page you can find all versions of the php package abordage/og-images. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download abordage/og-images
More information about abordage/og-images
Files in abordage/og-images
Package og-images
Short Description Generate Open Graph images (og:image, twitter:image, vk:image) for each site pages
License MIT
Homepage https://github.com/abordage/og-images
Informations about the package og-images
Open Graph Images Generator
Create Open Graph images (og:image, twitter:image, vk:image) for each (or some) site pages.
Use page title to create an eye-catching page preview when users share the link on social networks or instant messengers. Learn more about Open Graph.
Features:
- Image generation with your text and site name
- Fully customizable (see configuration)
- Small image size (15-50 Kb) with high resolution and quality (check it)
- Aspect ratios presets for popular social networks
▶ See examples
Requirements
- PHP 7.4 - 8.3
- The Imagick PHP extension
Installation
You can install the package via composer:
💡 Using Laravel? Check out abordage/laravel-og-images
Quick start
Note
All images are encoded inPNG
format as it provides the best ratio between size/quality. For the same reason, the package uses theImagick
driver - in tests, it showed an advantage in speed and final size of the generated images.
Usage
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:
If after generation you need to get sizes of the image, you can get it as follows:
Configuration
API Reference
Method | Returns | Added in | Changed in |
---|---|---|---|
make(string $text, string $preset = 'opengraph') |
self | 0.1.0 | 0.2.0 |
makeCustom(string $text, int $width, int $height) |
self | 0.2.0 | - |
get() |
string | 0.1.0 | - |
save(string $path) |
boolean | 0.1.0 | - |
getImageSizes() |
array | 0.3.0 | - |
Images aspect ratios
Preset | Aspect ratios | Docs |
---|---|---|
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 |
make(string $text, 'twitter') |
1200 x 600 (2:1) | |
make(string $text, 'vk') |
1200 x 536 (2.2:1) | vk |
Roadmap
Add ability to use gradients and images for the background.
Testing
Run all tests
or
or see https://github.com/abordage/og-images/actions/workflows/tests.yml
Feedback
Find a bug or have a feature request? Open an issue, or better yet, submit a pull request - contribution welcome!
Contributing
Please see CONTRIBUTING for details.
Credits
- Pavel Bychko (abordage)
- All Contributors
License
The MIT License (MIT). Please see License File for more information.
All versions of og-images with dependencies
ext-imagick Version *