Download the PHP package 53ny4/og-image without Composer

On this page you can find all versions of the php package 53ny4/og-image. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package og-image

OG Image Generator in PHP 1.6.1 (GD Driver)

Latest Version on Packagist License

NOTE: This project is still in development.


A simple and flexible PHP library for generating Open Graph (OG) (but really any type of) images with customizable backgrounds, text, and watermarks. Perfect for creating dynamic social media preview images for your website or application.

This project was inspired by my clients, each of them wanted to have a custom OG image for their website. One wanted to have a simple image with a quote, another wanted to have an avatar of the user displayed and so on. While there are projects like that and don't get me wrong, they are great, but they are not flexible enough for my needs.

On the other hand, Imagine/Imagine is a great library, but it has a bit of code to write to get the desired result.

say, watermark, for example, you have to write a bit of code to get the desired result.

It is simpler than native GD, but still. I wanted it to be straightforward and simple, since I'm using it quite often.

Done.


Example Image

NOTE: all highlighted elements are separate layers, so you can easily customize them.


Image background with text and watermark.


Resized image background with text. (see original image here)


Image background with for quote.


Color background with borders and text.

Fancy Memorial Example

There are 3 watermarks elements in this example: the logo, fancy frame and a portrait and 2 text elements: name and dates.

as used at ForeverAfter.Life - OG


Table of Contents

Features

Requirements

Installation

  1. Install the library using Composer:

  2. Clone the Repository:

  3. Install Dependencies:

    Navigate to the project directory and install the required packages using Composer.

    Ensure that the imagine/imagine package is installed and available in the project.


NOTE: only GD driver is used. Make sure that the GD library is installed and enabled in your PHP configuration.


Usage

Basic Usage

Here's a quick example of how to generate an OG image with a solid color background, border, watermark and custom text.

Setting Backgrounds

You can set the background of the image using a solid color or an image.

Solid Color Background

Image Background

Adding Borders

You can add borders to the background with custom width and color.

Adding Text

You can add multiple text elements to the image, each with its own styling and positioning.

Text Positioning

Position the text horizontally ('left', 'center', 'right') and vertically ('top', 'center', 'bottom').

Hint: you can use pixel values for custom positioning.

Text Styling

Customize the text color, size, and font.

Background for Text

Add a background rectangle behind the text with adjustable opacity.

Adding Watermarks

Add watermark image with customizable size, position, and opacity. (can be added multiple watermarks) Watermark treated as a separate layer, so you can add multiple watermarks and they can overlap each other.

Hint: watermark can be not only used as an actual watermark, but also as a logo or any other image. Also: you can use pixel values for custom positioning.

Custom Templates (How to)

Your custom templates should extend the OgImageTemplateBase.

Then you can add your custom methods to the template with specific properties that you want to set.

And then in your code, instead of using a bunch of parameters, you can just use it like this:

Result:

Full Example

Putting it all together:

Customization

Fonts

Padding and Alignment


Note: Ensure all file paths are correct and that necessary assets (fonts, images) are available in the specified locations. Adjust permissions as needed to allow the script to read and write files.

Disclaimer: This library uses the GD library for image manipulation.

License

This project is licensed under the MIT License



All versions of og-image with dependencies

PHP Build Version
Package Version
Requires php Version ^8.2
imagine/imagine Version ^1.3
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package 53ny4/og-image contains the following files

Loading the files please wait ....