Resizing An Image Online Compressor Photo Image Online Resize

Plugins, integrations, and SDKs

Compress Jpeg
Compressing An Image
Compress The Photo
  1. / picsmize-laravel
  2. Version: 1.0.1
  3. License: MIT
The official Laravel facade for Picsmize API

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

Quick Installation

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

$ composer require picsmize/picsmize-laravel

or add to your project's composer.json :

"require": {
"picsmize/picsmize-laravel": "dev-main"
}

...and run following command, to fetch the updated package from composer.json

$ composer update

Register provider and facade on your project's config/app.php file

'providers' => [
...,
Picsmize\PicsmizeLaravel\PicsmizeServiceProvider::class
]
'aliases' => [
...,
'Picsmize' => Picsmize\PicsmizeLaravel\Facades\Picsmize::class
]
Configuration

Publish the configuration for the package which will create the config file config/picsmize.php :

$ php artisan vendor:publish --provider="Picsmize\PicsmizeLaravel\PicsmizeServiceProvider"

The last step is to provide your Picsmize API Key by either setting app variable picsmize_apikey in your project's config/app.php file or by directly editing the config/picsmize.php file.

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 Laravel 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:

/**
* Import `Picsmize` Class
*/

use Picsmize;

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

Picsmize::fetch('https://www.website.com/image.jpg')

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

->compress(Picsmize::get("COMPRESS_MEDIUM"))

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

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

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

->filter(Picsmize::get("FILTER_BLUR"), array(
'mode' => "gaussian",
'value' => 10
))
->toJSON(function ($response) {
if ($response['status'] == false) {
throw new Exception($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'] == true) {
print ($response['output']['src']);
} else {
print ($response['message']);
}
});