2017 © Pedro Peláez
 

library image

Image library for layer like blending of images in PHP

image

manticorp/image

Image library for layer like blending of images in PHP

  • Sunday, February 14, 2016
  • by manticorp
  • Repository
  • 1 Watchers
  • 1 Stars
  • 8 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 1 Forks
  • 3 Open issues
  • 1 Versions
  • 14 % Grown

The README.md

Latest Stable Version Total Downloads Latest Unstable Version License, (*1)

# 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)

Installation

simply require the package in composer, (*7)

composer require manticorp/image

Usage

Simple example

<?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'>

Simple example 2

<?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 "
"; }

Magic Methods

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;

Available blending modes

Bold = Photoshop based., (*9)

  • Add
  • Atop
  • Blend
  • Blur
  • BumpMap
  • ChangeMask
  • Clear
  • Color
  • ColorBurn
  • ColorDodge
  • Colorize
  • Copy
  • CopyBlack
  • CopyBlue
  • CopyCyan
  • CopyGreen
  • CopyMagenta
  • CopyOpacity
  • CopyRed
  • CopyYellow
  • Darken
  • DarkenIntensity
  • DarkerColor
  • Default
  • Difference
  • Displace
  • Dissolve
  • Distort
  • Divide
  • DivideDST
  • DivideSrc
  • DST
  • DSTatop
  • DSTin
  • DSTout
  • DSTover
  • Exclusion
  • HardLight
  • HardMix
  • Hue
  • In
  • Lighten
  • LightenIntensity
  • LighterColor
  • LinearBurn
  • LinearDodge
  • LinearLight
  • Luminize
  • Luminosity
  • Mathematics
  • Minus
  • MinusDST
  • MinusSrc
  • Modulate
  • ModulusAdd
  • ModulusSubtract
  • Multiply
  • No
  • Normal
  • Out
  • Over
  • Overlay
  • Pegtoplight
  • PinLight
  • Plus
  • Replace
  • Saturate
  • Saturation
  • Screen
  • SoftLight
  • Src
  • SrcAtop
  • SrcIn
  • SrcOut
  • SrcOver
  • Subtract
  • Threshold
  • Undefined
  • VividLight
  • Xor

The Versions

14/02 2016

dev-master

9999999-dev

Image library for layer like blending of images in PHP

  Sources   Download

MIT

The Requires

  • php >=5.3.0