mistralys/application-utils-image

PHP image helper library for basic image operations and color management.

1.1.1 2024-11-14 13:26 UTC

This package is auto-updated.

Last update: 2024-11-14 13:39:52 UTC


README

PHP image helper library for basic image editing and color management.

Usage

Create an instance

use AppUtils\ImageHelper;

// From a file
$helper = ImageHelper::createFromFile('image.jpg');

// From a resource    
$resource = imagecreatefromjpeg('image.jpg');
$helper = ImageHelper::createFromResource($resource);

// New blank image
$helper = ImageHelper::createNew(200, 100);

Resize an image

use AppUtils\ImageHelper;

ImageHelper::createFromFile('image.jpg')
    ->resampleByWidth(200)
    ->save('resized.jpg');

Get image dimensions (including SVG)

use AppUtils\ImageHelper;

$size = ImageHelper::createFromFile('image.jpg')->getSize();

echo $size->toReadableString();