PHP code example of xj / yii2-kohanaimage

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

    

xj / yii2-kohanaimage example snippets


header("Content-Type: image/jpg");
$pathToFile = 'f:/1.jpg';
$pathToFile2 = 'f:/2.jpg';
echo Image::load($pathToFile)->render('png');
echo Image::load($pathToFile)->crop(100, 100)->render();
echo Image::load($pathToFile)->resize(100, 100, Image::INVERSE)->render();
echo Image::load($pathToFile)->resize(100, null)->render();
echo Image::load($pathToFile)->resize(null, 100)->render();
echo Image::load($pathToFile)->rotate(45)->render();
echo Image::load($pathToFile)->resize(400, null)->sharpen(20)->render();
echo Image::load($pathToFile)->rotate(45)->watermark(Image::load($pathToFile2))->render();