PHP code example of tigroid3 / php-imaginary

1. Go to this page and download the library: Download tigroid3/php-imaginary library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

tigroid3 / php-imaginary example snippets


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

$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');

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

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

$ composer 

"tigroid3/php-imaginary": "*"