PHP code example of compolomus / compomage
1. Go to this page and download the library: Download compolomus/compomage 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/ */
compolomus / compomage example snippets
use Compolomus\Compomage\Image;
ge('./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" />';