compolomus / compomage
Image helper
1.0
2022-07-19 17:13 UTC
Requires
- php: ^8.0
- ext-gd: *
- ext-imagick: *
Requires (Dev)
- laminas/laminas-coding-standard: ^1.0
- phpunit/phpunit: ^9.5
Suggests
- ext-xdebug: ^3.0
README
Установка:
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" />';