PHP code example of snappyimg / snappyimg-php

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

    

snappyimg / snappyimg-php example snippets


$snappy = new Snappyimg($appToken, $appSecret, Snappyimg::STAGE_DEMO);

$options = Options::fromDefaults(360, 420);
$url = $snappy->buildUrl($options, 'https://www.snappyimg.com/demo.jpg');

$options = Options::fromDefaults(360, 420)
    ->setResize(Snappyimg::RESIZE_FIT)
    ->setGravity(Snappyimg::GRAVITY_SMART)
    ->setEnlarge(FALSE)
    ->setFormat(Snappyimg::FORMAT_WEBP);