PHP Classes

PHP Image Manipulation Package: Perform multiple image manipulation operations

Recommend this page to a friend!
  Info   Documentation   View files Files   Install with Composer Install with Composer   Download Download   Reputation   Support forum   Blog    
Ratings Unique User Downloads Download Rankings
Not enough user ratingsTotal: 274 All time: 7,679 This week: 24Up
Version License PHP version Categories
image-manipulation 1.0.0MIT/X Consortium ...5.3PHP 5, Graphics
Description 

Author

This class can perform multiple image manipulation operations.

It provides a chained interface, so different operations can be perform a given image in the same code line. Currently it can perform the following filtering operations:

- Brightness
- Colorize
- Comic
contrast
convolution 3x3 filters
darken
dodge
edge detect
emboss
find edges
flip (horizonal, vertical, both)
gamma correction
gaussian blur
grayscale
mean remove
motion blur
negative
noise
old cardboard
opacity
pixelate
random blocks with custom size and color
replace color
reverse
scatter
selective blur
semi grayscale
sepia
sepia fast
sharpen
smooth
sobel edge detect
sobel edge enhance (based on convolution matrix)
true color
vignette

The package can also perform overlay operations with multiple images stacked over each other in layers. Several options can be configured like overlay opacity, start and end position and fill options.

The package can also create reflection effects creating a new image below with the reflex of another image.

It can also create images with the repetition of the same image multiple times on the same canvas until it fits.

Images can also be rotated by 90, 180, 270 degrees with an optional background color for those oncovered edges.

The package can also create thumbnails on the fly using several strategies like:

- Centered strategy: create a thumb from the center of an image. Ideal for creating square thumbs from not so square images
- Max strategy: resize the image to a max width or height keeping proportions. For example: when resizing an image (300x750) on max 500 pixels, the resulting image will be 200x500 pixels
- Percentage strategy: reduce the size of an image with a certain percentage.

It can as well create watermark to an image with possible positions at: top, bottom, left, right, center, top right, top left, bottom right, bottom left.

Picture of Elger van Boxtel
  Performance   Level  
Innovation award
Innovation award
Nominee: 1x

 

Documentation

IMAGEMANIPULATION

Build Status<br/> Fork me on GitHub: https://github.com/elgervb/imagemanipulation

Library to manipulate images using PHP's GD library. Most of the functionality is available through the ImageBuilder facade. This way chaining of image filters and thumbnailing is possible, like:

ImageBuilder::create( new \SplFileInfo('image.jpg') )
  ->contrast( 20 ) // increase contrast
  ->colorize( '#DB3636' ) // apply a bit of red the the image
  ->flip( ImageFilterFlip::FLIP_VERTICALLY ) // flip image vertically
  ->save( new \SplFileInfo( 'image.new.png' ) ) // save the jpg image as png with filters applied
  ->render( 80 ); // render to browser with quality 80

Installation

With composer.json:

	"require" : {
		"imagemanipulation" : "dev-master"
	},
	"repositories" : [{
			"type" : "vcs",
			"url" : "https://github.com/elgervb/imagemanipulation"
		}
	]

Requirements

PHP version >= 5.3 with GD library


FUNCTIONALITY

Filters

Lots of image filters. All of them listed below:

  • brightness
  • colorize
  • comic
  • contrast
  • convolution 3x3 filters
  • darken
  • dodge
  • edge detect
  • emboss
  • find edges
  • flip (horizonal, vertical, both)
  • gamma correction
  • gaussian blur
  • grayscale
  • mean remove
  • motion blur
  • negative
  • noise
  • old cardboard
  • opacity
  • pixelate
  • random blocks with custom size and color
  • replace color
  • reverse
  • scatter
  • selective blur
  • semi grayscale
  • sepia
  • sepia fast
  • sharpen
  • smooth
  • sobel edge detect
  • sobel edge enhance (based on convolution matrix)
  • true color
  • vignette

Overlay

Use an image as overlay on another image. Can be configured with overlay opacity, start and end position and fill options.

Reflection

Use the current image to make a reflection below the original image

Image repeater

Repeat images on a canvas, until it fits. This way we can create Warhol like images.

Rotate

Rotate images in degrees. When rotating an image not equal to 90, 180, 270 or 360 degrees, then optionally you can specify a background color for those oncovered edges.

Thumbnails

Create thumbnails on the fly. There are several strategies to use:

  • Centered strategy: create a thumb from the center of an image. Ideal for creating square thumbs from not so square images
  • Max strategy: resize the image to a max width or height keeping proportions. For example: when resizing an image (300x750) on max 500 pixels, the resulting image will be 200x500 pixels
  • Percentage strategy: reduce the size of an image with a certain percentage.

Watermarking

Add a watermark to your image. Possible positions are: top, bottom, left, right, center, top right, top left, bottom right, bottom left.


  Files folder image Files (89)  
File Role Description
Files folder imageimagemanipulation (9 files, 8 directories)
Files folder imagetests (6 files, 1 directory)
Plain text file composer.json Data Auxiliary data
Plain text file phar-bootstrap.php Conf. Configuration script
Plain text file PharClassLoader.php Class Configuration script
Plain text file phpunit.xml Data Auxiliary data
Plain text file README.md Doc. Auxiliary data

The PHP Classes site has supported package installation using the Composer tool since 2013, as you may verify by reading this instructions page.
Install with Composer Install with Composer
 Version Control Unique User Downloads Download Rankings  
 100%
Total:274
This week:0
All time:7,679
This week:24Up