2017 © Pedro Peláez
 

library php-image

Image lib

image

meriksk/php-image

Image lib

  • Tuesday, September 12, 2017
  • by meriksk
  • Repository
  • 1 Watchers
  • 0 Stars
  • 4 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 1 Versions
  • 0 % Grown

The README.md

PHP-Image Library

Latest Stable Version License, (*1)

The Image class offers a bunch of image processing features using GD or IMagick., (*2)

Requirements

  • PHP >=5.6

Supported Image Libraries

  • GD Library (>=2.0)
  • Imagick PHP extension (>=6.5.7)

Setup

The preferred way to install this extension is through Composer. If you do not have Composer, you may install it by following the instructions at getcomposer.org., (*3)

Either run, (*4)

composer require meriksk/php-image

or add, (*5)

"meriksk/php-image": "~1.0" 

to your composer.json and run composer update, (*6)

Usage

Open image

Because this class uses namespacing, when instantiating the object, you need to either use the fully qualified namespace:, (*7)

$image = new \meriksk\PhpImage\Image($filename);

or alias it:, (*8)

use \meriksk\PhpImage\Image;

$image = new Image($filename);

This class can use Imagick or GD extension - whichever is available. Imagick extension is preferred if is available. You can force the extension for manipulating images as follows:, (*9)

$image = new Image($filename, Image::DRIVER_IMAGICK);

Save image

Library supports three formats of image: 'jpeg', 'png' and 'gif'. By default they quality is set to 75. When saving to disk or outputting into the browser, the script assumes the same output type and quality as input., (*10)

$image->save($filename);

Save in a different type to the source:, (*11)

$image->save($filename, 60, 'png');

Output image

To render the image directly into the browser, you can call:, (*12)

$image->toScreen(60, 'png');

Resize

resize, (*13)

$image = $image->resize($width, $height, $allow_enlarge);

resize to width, (*14)

$image = $image->resizeToWidth($width, $allow_enlarge);

resize to height, (*15)

$image = $image->resizeToHeight($height, $allow_enlarge);

resize to best fit, (*16)

$image = $image->resizeToBestFit($max_width, $max_height, $allow_enlarge);

resize to long side, (*17)

$image = $image->resizeToLongSide($max, $allow_enlarge);

resize to short side, (*18)

$image = $image->resizeToShortSide($max, $allow_enlarge);

Crop

** manual crop **, (*19)

$image->crop($x, $y, $width, $height, $allow_enlarge);

** automatic crop **, (*20)

$image->autoCrop($width, $height, $position);

Thumbnail

$image->thumbnail($width, $height, $fill, $allow_enlarge);

Rotate image

Rotating is counter clockwise;, (*21)

Rotate on 90 degrees:, (*22)

$image->rotate(90);

Rotate on 45 degrees, and fill empty field with white color:, (*23)

$image->rotate(45, '#FFFFFF');

Flip image

Flip in vertical direction:, (*24)

$image->flip();

Flip in horisontal direction:, (*25)

$image->flip(Image::FLIP_HORIZONTAL);

Flip in both directions:, (*26)

$image->flip(Image::FLIP_BOTH);

Filters

todo, (*27)

The Versions

12/09 2017

dev-master

9999999-dev

Image lib

  Sources   Download

MIT

The Requires

  • php >=5.6.0

 

The Development Requires

by Marek Drugac

image resize gd imagick thumbnail scale