PHP code example of canerdogan / imgproxy

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

    

canerdogan / imgproxy example snippets


CanErdogan\ImgProxy\ImgProxyServiceProvider::class,

php artisan vendor:publish --provider="CanErdogan\\ImgProxy\\ImgProxyServiceProvider"

imgProxy('https://www.nasa.gov/sites/default/files/images/528131main_PIA13659_full.jpg', 640, 360)

use CanErdogan\ImgProxy\Contracts\ImageSignatureInterface;
use CanErdogan\ImgProxy\Image;

Route::get('/img-test', function () {
    $path      = 'https://www.nasa.gov/sites/default/files/images/528131main_PIA13659_full.jpg';
    $width     = 640;
    $height    = 360;
    $pic       = new Image;
    $pic->setOriginalPictureUrl($path)
        ->setWidth($width)
        ->setHeight($height)
        ->setResize('fit')
        ->setGravity('no')
        ->setEnlarge(0)
        ->setExtension('png');
    app()->instance(Image::class, $pic);
    $signature = app(ImageSignatureInterface::class);

    echo '
    Resized: <img src="' . config('img-proxy.base_url') . $signature->take() . '" alt="Resized">
    <br>
    Original: <img src="' . $path . '" alt="Original">
    ';

});