PHP code example of robotkudos / rkimage

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

    

robotkudos / rkimage example snippets



use RobotKudos\RKImage\ImageUploader;
use RobotKudos\RKImage\Size;
use RobotKudos\RKImage\Watermark;
use RobotKudos\RKImage\Position;

Route::post('/', function(Request $request) {
    $imageUploader = new ImageUploader();
    // With watermark image, watermark images should be in resources folder (below: resources/img/logo-watermark-light.png)
    $watermark = new Watermark(Position::BottomRight, 'img/logo-watermark-light.png', 'img/logo-watermark-light-x2.png');
    // save returns array of two files saved, if no retina requested, it'll be null
    return var_dump($imageUploader->save($request->myimage->path(), new Size(1500), $watermark));
    // ["image_url"] => "img/image_5f2aeaccc5a110.52811690.jpg" 
    // ["image_url_retina"]=> string(37) "img/image_5f2aeacd2086e3.79326949.jpg"
})