PHP Classes

PHP Image Manipulation Package: Perform multiple image manipulation operations

Recommend this page to a friend!
  Info   View files Documentation   View files View files (89)   DownloadInstall with Composer Download .zip   Reputation   Support forum   Blog    
Ratings Unique User Downloads Download Rankings
Not enough user ratingsTotal: 273 This week: 1All time: 7,683 This week: 560Up
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  
Name: Elger van Boxtel <contact>
Classes: 3 packages by
Country: The Netherlands The Netherlands
Age: ???
All time rank: 294378 in The Netherlands The Netherlands
Week rank: 411 Up9 in The Netherlands The Netherlands Up
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  
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

  Files folder image Files  /  imagemanipulation  
File Role Description
Files folder imagecolor (4 files)
Files folder imagefilter (37 files)
Files folder imageoverlay (1 file)
Files folder imagereflection (1 file)
Files folder imagerepeater (1 file)
Files folder imagerotate (1 file)
Files folder imagethumbnail (1 file, 1 directory)
Files folder imagewatermark (2 files)
  Plain text file Coordinate.php Class Class source
  Plain text file ImageBuilder.php Class Class source
  Plain text file ImageImageResource.php Class Class source
  Plain text file ImageResource.php Class Class source
  Plain text file ImageResourceException.php Class Class source
  Plain text file ImageType.php Class Class source
  Plain text file ImageUtil.php Class Class source
  Plain text file PresetFilter.php Class Class source
  Plain text file ResourceFactory.php Class Class source

  Files folder image Files  /  imagemanipulation  /  color  
File Role Description
  Plain text file Color.php Class Class source
  Plain text file ColorFactory.php Class Class source
  Plain text file ColorUtil.php Class Class source
  Plain text file IColor.php Class Class source

  Files folder image Files  /  imagemanipulation  /  filter  
File Role Description
  Plain text file FilterException.php Class Class source
  Plain text file IImageFilter.php Class Class source
  Plain text file ImageFilterBrightness.php Class Class source
  Plain text file ImageFilterColorize.php Class Class source
  Plain text file ImageFilterComic.php Class Class source
  Plain text file ImageFilterContrast.php Class Class source
  Plain text file ImageFilterConvolution.php Class Class source
  Plain text file ImageFilterDarken.php Class Class source
  Plain text file ImageFilterDodge.php Class Class source
  Plain text file ImageFilterEdgeDetect.php Class Class source
  Plain text file ImageFilterEmboss.php Class Class source
  Plain text file ImageFilterFindEdges.php Class Class source
  Plain text file ImageFilterFlip.php Class Class source
  Plain text file ImageFilterGammaCorrection.php Class Class source
  Plain text file ImageFilterGaussianBlur.php Class Class source
  Plain text file ImageFilterGrayScale.php Class Class source
  Plain text file ImageFilterMeanRemove.php Class Class source
  Plain text file ImageFilterMotionBlur.php Class Class source
  Plain text file ImageFilterNegative.php Class Class source
  Plain text file ImageFilterNoise.php Class Class source
  Plain text file ImageFilterOldCardboard.php Class Class source
  Plain text file ImageFilterOpacity.php Class Class source
  Plain text file ImageFilterPixelate.php Class Class source
  Plain text file ImageFilterRandomBlocks.php Class Class source
  Plain text file ImageFilterReplaceColor.php Class Class source
  Plain text file ImageFilterReverse.php Class Class source
  Plain text file ImageFilterScatter.php Class Class source
  Plain text file ImageFilterSelectiveBlur.php Class Class source
  Plain text file ImageFilterSemiGrayScale.php Class Class source
  Plain text file ImageFilterSepia.php Class Class source
  Plain text file ImageFilterSepiaFast.php Class Class source
  Plain text file ImageFilterSharpen.php Class Class source
  Plain text file ImageFilterSmooth.php Class Class source
  Plain text file ImageFilterSobelEdgeDetect.php Class Class source
  Plain text file ImageFilterSobelEdgeEnhance.php Class Class source
  Plain text file ImageFilterTrueColor.php Class Class source
  Plain text file ImageFilterVignette.php Class Class source

  Files folder image Files  /  imagemanipulation  /  overlay  
File Role Description
  Plain text file ImageFilterOverlay.php Class Class source

  Files folder image Files  /  imagemanipulation  /  reflection  
File Role Description
  Plain text file ImageFilterReflection.php Class Class source

  Files folder image Files  /  imagemanipulation  /  repeater  
File Role Description
  Plain text file ImageRepeater.php Class Class source

  Files folder image Files  /  imagemanipulation  /  rotate  
File Role Description
  Plain text file ImageFilterRotate.php Class Class source

  Files folder image Files  /  imagemanipulation  /  thumbnail  
File Role Description
Files folder imagepixelstrategy (4 files)
  Plain text file Thumbalizer.php Class Class source

  Files folder image Files  /  imagemanipulation  /  thumbnail  /  pixelstrategy  
File Role Description
  Plain text file CenteredPixelStrategy.php Class Class source
  Plain text file IPixelStrategy.php Class Class source
  Plain text file MaxPixelStrategy.php Class Class source
  Plain text file PercentagePixelStrategy.php Class Class source

  Files folder image Files  /  imagemanipulation  /  watermark  
File Role Description
  Plain text file ImageFilterWatermark.php Class Class source
  Plain text file WatermarkBuilder.php Class Class source

  Files folder image Files  /  tests  
File Role Description
Files folder imageimagemanipulation (1 file, 2 directories)
  Plain text file ImageFilterTestCase.php Test Unit test script
  Plain text file ImagemanipulationTestCase.php Test Unit test script
  Plain text file PHPUnitBootstrap.php Conf. Configuration script
  Image file sample.gif Data Auxiliary data
  Image file sample.jpg Data Auxiliary data
  Image file sample.png Data Auxiliary data

  Files folder image Files  /  tests  /  imagemanipulation  
File Role Description
Files folder imagecolor (3 files)
Files folder imagefilter (13 files)
  Plain text file ImageResourceTest.php Test Unit test script

  Files folder image Files  /  tests  /  imagemanipulation  /  color  
File Role Description
  Plain text file ColorFactoryTest.php Test Unit test script
  Plain text file ColorTest.php Test Unit test script
  Plain text file ColorUtilTest.php Test Unit test script

  Files folder image Files  /  tests  /  imagemanipulation  /  filter  
File Role Description
  Plain text file ImageFilterBrightnessTest.php Test Unit test script
  Plain text file ImageFilterColorizeTest.php Test Unit test script
  Plain text file ImageFilterContrastTest.php Test Unit test script
  Plain text file ImageFilterConvolutionTest.php Test Unit test script
  Plain text file ImageFilterDarkenTest.php Test Unit test script
  Plain text file ImageFilterDodgeTest.php Test Unit test script
  Plain text file ImageFilterEdgeDetectTest.php Test Unit test script
  Plain text file ImageFilterEmbossTest.php Test Unit test script
  Plain text file ImageFilterFindEdgesTest.php Test Unit test script
  Plain text file ImageFilterFlipTest.php Test Unit test script
  Plain text file ImageFilterGaussianBlurTest.php Test Unit test script
  Plain text file ImageFilterGrayscaleTest.php Test Unit test script
  Plain text file ImageFilterMeanRemoveTest.php Test Unit test script

 Version Control Unique User Downloads Download Rankings  
 100%
Total:273
This week:1
All time:7,683
This week:560Up