PHP code example of xicrow / php-image

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

    

xicrow / php-image example snippets


use Xicrow\PhpImage\Image\Action\FilterGreyScale;
use Xicrow\PhpImage\Image\Action\ResizeCrop;
use Xicrow\PhpImage\Image\Adapter\GDLibrary;

$strImagePath = '/path/to/image.jpg';
$oAdapter     = new GDLibrary($strImagePath);
$oAdapter->addAction(new ResizeCrop(500, 500));
$oAdapter->addAction(new FilterGreyScale());
$oAdapter->save('/path/to/converted/image.jpg');

use Xicrow\PhpImage\Image\Action\DrawLine;
use Xicrow\PhpImage\Image\Action\FilterColorize;
use Xicrow\PhpImage\Image\Action\FilterContrast;
use Xicrow\PhpImage\Image\Action\ResizeCrop;
use Xicrow\PhpImage\Image\Adapter\GDLibrary;

$strImagePath = '/path/to/image.jpg';
$oAdapter     = new GDLibrary($strImagePath);
$oAdapter->addAction(new ResizeCrop(500, 500));
$oAdapter->addAction(new FilterColorize(10, 25, 10));
$oAdapter->addAction(new FilterContrast(15));
$oAdapter->addAction(new DrawLine(25, 0, 25, 500));
$oAdapter->addAction(new DrawLine(475, 0, 475, 500));
$oAdapter->save('/path/to/converted/image.jpg');
bash
composer