freshleafmedia/glide-dimension-watermark

A Glide manipulation which overlays the images dimensions onto an image.

1.0.0 2022-11-27 14:51 UTC

This package is auto-updated.

Last update: 2024-04-29 04:47:54 UTC


README

Automatically add text to an image showing the dimensions.

Overview

It is common when using placeholder images to show the images dimensions in the center of the image. This library is a Glide manipulator which will do this and automatically adjust text size.

500x300 100x200

Photo by Robert Bye on Unsplash

Installation

composer require freshleafmedia/glide-dimension-watermark

Usage

use Freshleafmedia\DimensionWatermark\DimensionWatermark;

// Setup Glide server. See https://glide.thephpleague.com/2.0/simple-example/
$server = League\Glide\ServerFactory::create([
    // ...
]);


// Add DimensionWatermark to the manipulators array
$manipulators = $server->getApi()->getManipulators();

array_splice($manipulators, count($manipulators) - 1, 0, [new DimensionWatermark()]);

$server->getApi()->setManipulators($manipulators);

The manipulator runs when the dwm parameter is set to any value. For example /image.jpg?dwm=1 or /image.jpg?w=100&fm=webp&dwm=1

Note: It is important that DimensionWatermark is added after the Size manipulator and before Encode manipulator

License

See LICENSE