Skip to content

tigroid3/php-imaginary

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

php-imaginary

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
)