2017 © Pedro Peláez
 

library gw-image-editor

Simple PHP image manipulation library

image

gwa/gw-image-editor

Simple PHP image manipulation library

  • Tuesday, April 26, 2016
  • by gwa
  • Repository
  • 5 Watchers
  • 2 Stars
  • 1,802 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 1 Forks
  • 1 Open issues
  • 11 Versions
  • 7 % Grown

The README.md

gwImageEditor

A PHP image editor library that uses the bundled GD library., (*1)

Scrutinizer Code Quality Build Status, (*2)

Provides a simple and intuitive interface for typical editing, cropping, resizing and filtering actions on existing images., (*3)

Typical use cases:, (*4)

  • Scaling and cropping uploaded images to within constraints
  • Creating different sized versions of an image
  • Adding watermarks

Installation

Install through composer:, (*5)

composer require gwa/gw-image-editor, (*6)

Usage

use Gwa\Image\ImageEditor;

// create an editor using an existing image
$editor = new ImageEditor('path/to/image.png');

// resize image to within 640 x 480 px, maintaining aspect ratio
$editor->resizeToWithin(640, 480)
    ->save();

// resize image to exactly 640 x 480 px, cropping any overhang
$editor->resizeTo(640, 480)
    ->save();

// resize image to exactly 640px width, preserving aspect ratio
$editor->resizeTo(640)
    ->save();

// resize image to exactly 480px height, preserving aspect ratio
$editor->resizeTo(null, 480)
    ->save();

// crop the image: x, y, width, height
$editor->crop(10, 10, 100, 100)
    ->save();

// methods can be chained
// - create and save medium image with max width and height of 500px
// - create and save thumbnail image with exact dimensions of 100px x 100px
$editor = new ImageEditor('path/to/original.jpg');
$editor->resizeToWithin(500, 500)
    ->saveAs('path/to/medium.jpg')
    ->resizeTo(100, 100)
    ->saveAs('path/to/thumbnail.jpg')
    ->saveAs('path/to/thumbnail.png', IMAGETYPE_PNG);

// another image can be "pasted" in (e.g. a watermark)
// - paste watermark into bottom right corner
$editor = new ImageEditor('path/to/original.jpg');
$iw = $editor->getWidth();
$ih = $editor->getHeight();

$watermark = new ImageEditor('path/to/watermark.png');
$ww = $watermark->getWidth();
$wh = $watermark->getHeight();

$padding = 10;

$editor->pasteImage($watermark, $iw - $ww - $padding, $ih - $wh - $padding)
    ->saveAs('path/to/watermarked.jpg');

// there are also filter methods available
$editor = new ImageEditor('path/to/original.jpg');
$editor->grayscale()
    ->coloroverlay(0, 0, 0, 50) // 50% black overlay
    ->colorize(255, 0, 0, 0) // rgba

Tests

PHPUnit, (*7)

$ ./vendor/bin/phpunit -c tests/phpunit.xml --coverage-html=tests/_report tests

Code style (PSR-2), (*8)

$ ./vendor/bin/phpcs --standard=PSR2 src

The Versions

26/04 2016

dev-master

9999999-dev https://github.com/gwa/gwImageEditor

Simple PHP image manipulation library

  Sources   Download

MIT

The Requires

  • ext-exif *
  • ext-mbstring *
  • php >=5.4

 

The Development Requires

26/04 2016

v3.3.2

3.3.2.0 https://github.com/gwa/gwImageEditor

Simple PHP image manipulation library

  Sources   Download

MIT

The Requires

  • ext-exif *
  • ext-mbstring *
  • php >=5.4

 

The Development Requires

17/09 2015

v3.3.1

3.3.1.0 https://github.com/gwa/gwImageEditor

Simple PHP image manipulation library

  Sources   Download

MIT

The Development Requires

17/05 2015

v3.3

3.3.0.0 https://github.com/gwa/gwImageEditor

Simple PHP image manipulation library

  Sources   Download

MIT

The Development Requires

17/05 2015

v3.2.1

3.2.1.0 https://github.com/gwa/gwImageEditor

Simple PHP image manipulation library

  Sources   Download

MIT

The Development Requires

17/05 2015

v3.2.0

3.2.0.0 https://github.com/gwa/gwImageEditor

Simple PHP image manipulation library

  Sources   Download

MIT

The Development Requires

16/05 2015

v3.1.0

3.1.0.0 https://github.com/gwa/gwImageEditor

Simple PHP image manipulation library

  Sources   Download

MIT

The Development Requires

15/05 2015

v3.0.1

3.0.1.0 https://github.com/gwa/gwImageEditor

Simple PHP image manipulation library

  Sources   Download

MIT

The Development Requires

15/05 2015

v3.0

3.0.0.0 https://github.com/gwa/gwImageEditor

Simple PHP image manipulation library

  Sources   Download

MIT

The Development Requires

03/09 2014

v2.0

2.0.0.0 https://github.com/gwa/gwImageEditor

Simple PHP image manipulation library

  Sources   Download

MIT

The Requires

 

02/06 2014

1.0.0

1.0.0.0 https://github.com/gwa/gwImageEditor

Simple PHP image manipulation library

  Sources   Download

MIT