2017 © Pedro Peláez
 

library php-image-tools

An image manipulation library utilizing Imagick.

image

kingjerod/php-image-tools

An image manipulation library utilizing Imagick.

  • Monday, June 8, 2015
  • by kingjerod
  • Repository
  • 0 Watchers
  • 0 Stars
  • 0 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 1 Forks
  • 0 Open issues
  • 1 Versions
  • 0 % Grown

The README.md

PHPImageTools

Build Status Coverage Status Software License, (*1)

PHP library for image manipulation, uses modifiers to alter images. Simplifies some of the complicatedness of Imagick. Has a factory to help load remote images, and also find/manipulate images in folders., (*2)

Installation

This library requires PHP 5.4 and the Imagick PHP plugin to be installed. On some Unix systems this command should work:, (*3)

sudo apt-get install php5-imagick, (*4)

Once you have Imagick installed, use composer to install the library:, (*5)

composer require kingjerod\php-image-tools, (*6)

Usage

ImageTools has two main classes, the Image class and the Modifier class. The Modifier classes are used to change an image, either through resizing, cropping or adding text. Multiple modifiers can be applied to an image, and the same modifier can be applied to multiple images., (*7)

Examples

First use the factory to load an image:

$factory = new ImageFactory();
$image = $factory->createFromLocalFile('/images/apple.png');

Once you have the image you can use different modifiers to change it:

Scale an image:
$scale = new Scale(200, 300); //width, height
$image->modify($scale);
$image->save('/images/appleBig.png');
Change opacity:
$opacity= new Opacity(0.8); //80% opacity (mostly visible)
$image->modify($opacity);
$image->save('/images/appleBig.png');
Add a watermark:
$text = new Text(10, 40, 'Arial.tff', '#000', 0.3, 24, 'Copyright XYZ');
$image->modify($text);
$image->save('/images/appleCopyright.png');
Merge two images together
$image2 = $factory->createFromLocalFile('/images/orange.png');
$merge = new Merge(10, 20, $image2);
$image->modify($merge);
$image->save('/images/appleAndOrange.png');
Do a bunch of cool things
$image2 = $factory->createFromLocalFile('/images/orange.png');
$merge = new Merge(10, 20, $image2);
$image->modify($merge);
$text = new Text(10, 40, 'Arial.tff', '#000', 0.3, 24, 'Copyright XYZ');
$image->modify($text);
$opacity= new Opacity(0.8); //80% opacity (mostly visible)
$image->modify($opacity);
$image->save('/images/appleAndOrangeCrazy.png');

Custom Modifiers

Creating your own modifiers is easy. Simple create your own class, and implement the ModifierInterface. It has one function:, (*8)

public function modify(Image $image);, (*9)

The Versions

08/06 2015

dev-master

9999999-dev https://github.com/kingjerod/php-image-tools

An image manipulation library utilizing Imagick.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Jerod King

image manipulation imagick imagemagick processing editing watermark