dev-master
9999999-devImage library for layer like blending of images in PHP
MIT
The Requires
- php >=5.3.0
Wallogit.com
2017 © Pedro Peláez
Image library for layer like blending of images in PHP
# Manticorp\Image, (*2)
An image library that gives photoshop-like layer blending image capabilities., (*3)
Requires EITHER the PHP GD image library (VERY slow) OR Imagick (fast!), (*4)
As an example, using GD image library on my i7 computer with 16GB ram, blending two 500px square images takes over 4 seconds., (*5)
This is mostly due to PHP having to iterate over every pixel., (*6)
simply require the package in composer, (*7)
composer require manticorp/image
<?php
$filename1 = 'baseimage.png';
$filename2 = 'topimage.png';
$base = new Manticorp\Image($filename1);
$top = new Manticorp\Image($filename2);
$dim = 500;
$base->setDimensions($dim, $dim);
$top->setDimensions($base->getDimensions());
$bottom->setOutputFn('./temp/output.png');
$opacity = 1;
$fill = 1; // Currently not implemented
$output = clone $bottom;
$output->blendWith($top, 'Overlay', $opacity, $fill);
echo $output->getImgTag(); // <img src='./temp/output.png'>
<?php
$filename1 = 'baseimage.png';
$filename2 = 'topimage.png';
$modes = Manticorp\Image::getAvailableBlendingModes();
$base = new Manticorp\Image($filename1);
$top = new Manticorp\Image($filename2);
$dim = 200;
$base->setDimensions($dim, $dim);
$top->setDimensions($base->getDimensions());
$opacity = 1;
$fill = 1; // Currently not implemented
foreach($modes as $mode){
$output = clone $base;
$output->setOutputFn('./output-' . $mode . '.png');
$output->blendWith($top, $mode, $opacity, $fill);
echo "
".$mode."
";
echo $output->getImgTag(); //
echo "
";
}
An array of magic methods are also available, (*8)
<?php $filename1 = 'baseimage.png'; $filename2 = 'topimage.png'; $modes = Manticorp\Image::getAvailableBlendingModes(); $base = new Manticorp\Image($filename1); $top = new Manticorp\Image($filename2); $dim = 200; $base->setDimensions($dim, $dim); $top->setDimensions($base->getDimensions()); $opacity = 1; $fill = 1; // Currently not implemented $base->overlayWith($top, $opacity, $fill); echo $base;
Bold = Photoshop based., (*9)
Image library for layer like blending of images in PHP
MIT