PHP code example of pixaven / pixaven-php

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

    

pixaven / pixaven-php example snippets




// Pass your Pixaven API Key to the constructor
$pix = new Pixaven\Pixaven('your-api-key');

// Upload an image from disk, resize it to 100 x 75,
// automatically enhance, and adjust sharpness parameter.
$pix
    ->upload('path/to/input.jpg')
    ->resize(array(
        'width' => 100,
        'height' => 75
    ))
    ->auto(array(
        'enahnce' => true
    ))
    ->adjust(array(
        'unsharp' => 10
    ))
    ->toJSON(function ($error, $meta) {
        if (!empty($error)) {
            throw new Exception($error);
        }

        // You'll find the full JSON metadata within the `meta` variable
    });



// Pass your Pixaven API Key to the constructor
$pix = new Pixaven\Pixaven('your-api-key');

// Provide a publicly available image URL with `fetch()` method,
// apply Gaussian blur using PNG as the output format.
// We'll also use `toFile()` method and stream the output image to disk
$pix
    ->fetch('https://www.website.com/image.jpg')
    ->filter(array(
        'blur' => array(
            'mode' => 'gaussian',
            'value' => 10
        )
    ))
    ->output(array(
        'format' => 10
    ))
    ->toFile('path/to/output.png', function ($error, $meta) {
        if (!empty($error)) {
            throw new Exception($error);
        }

        // You'll find the full JSON metadata within the `meta` variable
    });
bash
$ composer