dev-master
9999999-devImage lib
MIT
The Requires
- php >=5.6.0
The Development Requires
by Marek Drugac
image resize gd imagick thumbnail scale
Wallogit.com
2017 © Pedro Peláez
Image lib
The Image class offers a bunch of image processing features using GD or IMagick., (*2)
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)
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);
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');
To render the image directly into the browser, you can call:, (*12)
$image->toScreen(60, 'png');
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);
** manual crop **, (*19)
$image->crop($x, $y, $width, $height, $allow_enlarge);
** automatic crop **, (*20)
$image->autoCrop($width, $height, $position);
$image->thumbnail($width, $height, $fill, $allow_enlarge);
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 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);
todo, (*27)
Image lib
MIT
image resize gd imagick thumbnail scale