tigroid3/php-imaginary

SDK for https://github.com/h2non/imaginary

Installs: 4 635

Dependents: 0

Suggesters: 0

Security: 0

Stars: 1

Watchers: 1

Forks: 1

Open Issues: 0

pkg:composer/tigroid3/php-imaginary

1.03 2020-06-30 20:32 UTC

This package is auto-updated.

Last update: 2025-09-29 02:51:36 UTC


README

SDK for https://github.com/h2non/imaginary

Either run

$ composer require tigroid3/php-imaginary

or add

"tigroid3/php-imaginary": "*"

to the require section of your composer.json file.

Basic usage:

Set service uri

$client = new ImaginaryClient();
$client->setServiceUri('http://imaginary:9005');

Image processing

$imaginaryResource = Imaginary::new()
    ->setUploadFilePath('/home/user/test.jpg')
    ->smartCrop(300, 300)
    ->zoom(2)
    ->convert(Imaginary::FORMAT_WEBP)
    ->execute();
        
//save new image        
file_put_contents('test.webp', $imaginaryResource->getContent());
//or 
move_uploaded_file($imaginaryResource->getPathProcessedFile(), 'test.webp');

Image info

$imageInfo = Imaginary::new()
    ->setUploadFilePath('/home/user/tmp/test.jpg')
    ->info();

Example response

Array
(
    [width] => 3840
    [height] => 2400
    [type] => jpeg
    [space] => srgb
    [hasAlpha] =>
    [hasProfile] =>
    [channels] => 3
    [orientation] => 0
)