PHP code example of sinasalek / silex-imagine-provider

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

    

sinasalek / silex-imagine-provider example snippets


use Imagine\Image\Box;
use Neutron\Silex\Provider\ImagineServiceProvider;
use Silex\Application;
use Symfony\Component\HttpFoundation\Request;

$app = new Application();
// detect a driver for you
$app->register(new ImagineServiceProvider());
// OR choose your own driver
$app->register(new ImagineServiceProvider(), array('imagine.driver' => 'Gmagick'));

$app->match('/image-resize', function(Request $request) {
    $app['imagine']
            ->open($request->files->get('image')->getPathname())
            ->resize(new Box(320, 240))
            ->save('/path/to/data/image-resized.jpg');

    return 'Image resized !';
});
$app->run();