PHP code example of unglud / laravel-image

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

    

unglud / laravel-image example snippets


use Unglued\LavaImage\Facades\LavaImage;

$fileHash = LavaImage::save('http://lorempixel.com/300/300/');

// $fileHash == 203bad62
// and file stored in /public/uploads/2/0/203bad62.jpg

// now you can save hash to file in your storage
$myModel = new MyModel();
$myModel->image = $fileHash;
$myModel->save();

LavaImage::save('http://lorempixel.com/300/300/', [100,100]);

// save image from file
LavaImage::save('public/foo.jpg');

// or save image from binary data
LavaImage::save(file_get_contents('public/foo.jpg'));

// save image from gd resource
LavaImage::save(imagecreatefromjpeg('public/foo.jpg'));

// save image directly from an url
LavaImage::save('http://example.com/example.jpg');

// save image directly from Laravel file upload
LavaImage::save(Input::file('photo'));

$hash = '203bad62'
LavaImage::getImage($hash);
// will return http://example.com/uploads/2/0/203bad62.jpg

LavaImage::getImage($hash, true);
// will return absolute path /home/var/laravel/public/uploads/2/0/203bad62.jpg


php artisan vendor:publish