PHP code example of picsmize / picsmize-php

1. Go to this page and download the library: Download picsmize/picsmize-php 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/ */

    

picsmize / picsmize-php example snippets




/**
* Initialize `Picsmize` Class
*/

$picsmize = new Picsmize('your-api-key');

/**
* Use of fetch() method
*/

$picsmize->fetch('https://www.website.com/image.jpg')

/**
* Use of compress() method with medium mode
*/

->compress(Picsmize::COMPRESS_LOW)

/**
* Use of resize() method with auto mode
* and width set to 400
*/

->resize(Picsmize::RESIZE_AUTO, array(
'width' => 400
))

/**
* Use of filter() blur method with gaussian mode
* and value set to 10
*/

->filter(Picsmize::FILTER_BLUR, array(
'mode' => 'gaussian',
'value' => 10
))

/**
* Call toJSON() on the final step and return the JSON response
*/

->toJSON(function ($response) {
/**
* You'll find the full JSON metadata array within the `$response` variable.
* Remember to always check if the `status` property is set to `true`.
*/

if ($response['status'] == false) {
throw new Exception($response['message']);
}

print_r($response);
});
bash
$ composer