Resizing An Image Online Compressor Photo Image Online Resize

Plugins, integrations, and SDKs

Compress The Photo
  1. / picsmize-php
  2. Version: 1.0
  3. License: MIT
The official PHP facade for Picsmize API

Click Here to go Picsmize API docs for full API reference.

Quick Installation

To install the Picsmize library, the syntax for installing the command line goes like this;

$ composer require picsmize/picsmize-php
Configuration

Load the Picsmize library into your page

require_once 'Picsmize/Picsmize.php';

If you don't have your API Key just yet, you can Sign Up for a free account.

And That's it! Start optimizing..!

Quick Example

This Picsmize PHP library allows all the operations available with the Picsmize API. The following example uses image fetch, compress, resize and filter with different mode and get the output file directly with toJSON() method:

/**
* 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);
});