PHP code example of rostenkowski / resize

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

    

rostenkowski / resize example snippets




use Rostenkowski\Resize\Meta;
use Rostenkowski\Resize\File;
use Rostenkowski\Resize\Request;
use Rostenkowski\Resize\ImageStorage;
use Nette\Application\Responses\FileResponse;
use Nette\Http\FileUpload;
use Nette\Utils\Image;

// create storage
$storage = new ImageStorage('/data/images', '/www/images', '/images/');

// add an image from file
$storage->add(File $image, Meta $meta);

// add a HTTP uploaded file
$storage->upload(FileUpload $file, Meta $meta);

// check that an image already exists in the storage
$storage->contains(Meta $meta);

// fetch original
$storage->original(Meta $meta);

// rotate image
$storage->rotate(Meta $meta, 90); // Meta

// downloaded requested thumbnail
$storage->download(Request $request); // Nette\Application\Responses\FileResponse

// fetch requested thumbnail
$storage->fetch(Request $request);

// link requested thumbnail
$storage->link(Request $request);

// output requested thumbnail to stdout
$storage->send(Request $request);

bin/run-tests.sh
 _____ ___  ___ _____ ___  ___
|_   _/ __)( __/_   _/ __)| _ )
  |_| \___ /___) |_| \___ |_|_\  v2.0.x

PHP 5.6.5 (cgi-fcgi) | php-cgi -n -c tests/php.ini | 1 thread

.............

OK (13 tests, 2.7 seconds)