yilanboy/preview

Generate the preview image

1.0.1 2024-12-21 10:40 UTC

This package is auto-updated.

Last update: 2025-05-21 12:06:33 UTC


README

A simple package to generate preview image.

Installation

Install the package with composer.

composer require yilanboy/preview

Then create an image builder.

use Yilanboy\Preview\Image\Builder;

(new Builder())
    ->size(width: 1200, height: 600)
    ->backgroundColor('#777bb3')
    ->header(text: 'Preview', color: 'white', fontSize: 75)
    ->title(text: 'A simple PHP package to create preview image', color: 'white', fontSize: 50)
    ->output();

This code will display the following image on the web page.

preview

You can modify the text on the preview image.

Currently, the text only support english and chinese.

Start a Local Server to Show the Image

There is a output.php file in examples folder, you can simply start a local server to see the image in browser.

php -S localhost:8000 examples/output.php

Then open your browser and visit localhost:8000.

Run Tests

composer run-tests