compolomus/compomage

1.0 2022-07-19 17:13 UTC

This package is auto-updated.

Last update: 2024-11-06 01:08:07 UTC


README

License

Build Status Scrutinizer Code Quality Code Climate Downloads Code Coverage

Установка:

composer require compolomus/compomage

Применение:

use Compolomus\Compomage\Image;

require __DIR__ . '/vendor/autoload.php';


/* Local file */
$img = new Image('./examples/crop/bee.jpg'); // Auto check Imagick or GD default

$img->grayscale()
    ->rotate(45)
    ->flop();

echo '<img src="data:image/png;base64,' . $img->getBase64() . '" alt="base64_image" style="background-color: orange;" />';

/* base64 source */

$base64_image = base64_encode(file_get_contents('./examples/crop/bee.jpg'));

$img = new Image($base64_image, Image::GD);

$img->resizeBy('percent', 150)
    ->flip();

echo '<img src="data:image/png;base64,' . $img->getBase64() . '" alt="base64_image" />';

/* URL file */

$URL_image = 'https://4.bp.blogspot.com/-P_yzboTrLUM/WGP4FUvVAQI/AAAAAAAABGc/SkRu_mOPKOwxsxLic-dBhugEyvPgvLEqgCLcB/s320/1.png';

$img = new Image($URL_image, Image::IMAGICK);

$img->resizeByWidth(600)
    ->resizeByHeight(350);
    
echo '<img src="data:image/png;base64,' . $img->getBase64() . '" alt="base64_image" />';