elgervb/imagemanipulation

Library for image manipulation in PHP with GD

1.2.0 2015-09-02 12:32 UTC

This package is not auto-updated.

Last update: 2024-10-24 16:12:28 UTC


README

Build Status Latest Stable Version
Fork me on GitHub: https://github.com/elgervb/imagemanipulation Bitdeli Badge

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" : {
		"elgervb/imagemanipulation": "^1.0"
	}

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
  • duotone
  • edge detect
  • emboss
  • find edges
  • flip (horizonal, vertical, both)
  • gamma correction
  • gaussian blur
  • grayscale
  • hue rotate
  • mean remove
  • motion blur
  • negative
  • noise
  • old cardboard
  • opacity
  • pixelate
  • random blocks with custom size and color
  • replace color
  • reverse
  • rounded corners
  • 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.

Examples

Thumbnails

You can create thumbnails in several ways

centered

create a thumbnail which is centered in the middle of the image

Examples
Centered Thumb Centered Thumb Centered Thumb

max

resize the image to a max width or height keeping proportions, thus restraining the image to a certain size

Examples
Max Thumb Max Thumb Max Thumb

percentage

reduce a image with a certain percentage

Examples
Max Thumb Max Thumb Max Thumb

square

Examples
Centered Thumb Centered Thumb Centered Thumb

Available Filters

blocks

Add random blocks to an image with custom size and color

Examples
Blocks Filter Blocks Filter Blocks Filter

brightness

Adjust the brightness of the image, either lighter or darker

Examples
Brightness Filter Brightness Filter Darker Brightness Filter Lighter

colorize

Blends a fill color with the image

Examples
Colorize Filter Colorize Filter red Colorize Filter green

comic

Apply a sketchy comic filter to an image

Examples
Comic Filter Comic Filter Comic Filter

contrast

Changes the contrast of the image

Examples
Contrast Filter Contrast Filter Contrast Filter

###darken Adjust the brightness of the image, either darker or lighter

Examples
Darken Filter Darken Filter Lighter Darken Filter Darker

###dodge Dodge an image, resulting in a darker image

Examples
Dodge Filter Dodge Filter Lighter Dodge Filter Darker

###duotone Duotone filter. Enhances Red, Green or Blue or a combination

Examples
Dodge Filter Dodge Filter Lighter Dodge Filter Darker

###edgedetect Uses edge detection to highlight the edges in the image

Examples
Edge detect Filter

###emboss Embosses the image

Examples
Edge detect Filter

###findedges Find the edges in an image without color loss

Examples
Edge detect Filter

###flip Flips an image

Examples
Flip Filter Flip Filter Vertical Flip Filter Horizontal

###gammacorrection Applies gamma correction

Examples
Gamma Correction Filter Gamma Correction Vertical FlipGamma Correction Horizontal

###gaussianblur Blurs the image using the Gaussian method.

Examples
Gaussian Blur Filter

###grayscale Converts the colors to grayscale

Examples
Gaussian Blur Filter

###huerotate Rotete the hue of the image

Examples
Hue Rotate Filter Hue Rotate Filter Hue Rotate Filter

###meanremove Uses mean removal to achieve a "sketchy" effect

Examples
Gaussian Blur Filter

###motionblur Motion blurs the image

Examples
Gaussian Blur Filter

###negative Create a negative of an image

Examples
Gaussian Blur Filter

###noise add noise to the image

Examples
Noise Filter Noise Filter Noise Filter

###oldcardboard Image filter to give the image an old cardboard look

Examples
Gaussian Blur Filter

###opacity Sets the opacity of an image

Examples
Opacity Filter Opacity Filter Opacity Filter

###pixelate Pixelate an image

Examples
Pixelate Filter Pixelate Filter Pixelate Filter

###rotate Rotate an image over an angle

Examples
Rotate Filter Rotate Filter Rotate Filter

###scatter Scatter pixels around in a random way

Examples
Scatter Filter Scatter Filter Scatter Filter

###selectiveblur Image filter Selective Blur

Examples
Selective blur Filter

###sepia Apply sepia to the image

Examples
Sepia Filter Sepia Filter Sepia Filter

###semigrayscale Applies grayscale to an image, optionally add a grayscale percentage

Examples
Sepia Filter Sepia Filter Sepia Filter

###sepiafast Apply sepia to the image (fast)

Examples
Sepia fast Filter Sepia fast Filter Sepia fast Filter

###sharpen Sharpens the image

Examples
Sepia fast Filter

###smooth Makes the image smoother.

Examples
Smooth Filter Smooth Filter Smooth Filter

###sobel Sobel edge detect (extremely slow...)

Examples
Sobel Edge Detect Filter

###sobeledge Sobel edge enhance

Examples
Sobel Edge Detect Filter

###truecolor Makes the image smoother.

Examples
Smooth Filter Smooth Filter Smooth Filter

###vignette Applies a darker mask around the edges of the image

Examples
Smooth Filter