ImageEditor is a wrapper of gd functions. Firstly, it was working only in yii-application context, but not now.
How to start: Create from existing file or make an empty area
$image = ImageEditor::createFromFile($filename);
// or
$image = ImageEditor::createWithSize($width, $height);
// or
$image = ImageEditor::createFromResource(imagecreatetruecolor(90, 90));- width - width of image
- height - height of image
- resource - original gd-resource of image (you can pass it directly to image-gd functions)
can minimize and maximize image:
- zoomWidthTo(int $size) - changes proportionally image width to
$size - zoomHeightTo(int $size) - changes proportionally image height to
$size
can only minimize image:
- decreaseWidthTo(int $size) - decreases proportionally image width to
$size, if needed - decreaseHeightTo(int $size) - decreases proportionally image height to
$size, if needed - decreaseTo(int $size) - decreases proportionally larger side to
$size, if needed
can do everything you ask it for:
- resize(int $width, int $height) - resizes an image to
$widthX$height
- crop($x, $y, $x2, $y2) - cuts a rectangular piece of image
- decreaseSide($side, int $size) - deletes a piece of image from specific side. For example, if $side=top and $size=100, 100px from top will be deleted.
- rotate($angle, $bgColor = 0) - rotates an image.
Trueequals 90°,Falseequals -90°. - horizontalFlip() - flips an image horizontally.
- verticalFlip() - flips an image vertically.
- appendImageTo($side, ImageEditor $appendix, int $modifiers) - appends an image (
$appendix) to current image at$side(top|bottom|left|right). - placeImageAt($x, $y, ImageEditor $image) - places an image atop current image at
$xX$y. - placeImageAtCenter(ImageEditor $image) - places an image in the center of current image.
- saveToFile($filename, $format, $quality) - saves image to disk.
Possible
$formatvalues: jpeg, png, gif, wbmp. Quality is an integer value between 0 (worst) and 100 (best).
- ImageEditor repo: https://github.com/wapmorgan/ImageEditor
- ImageEditor testing script: https://github.com/wapmorgan/ImageEditor-test
- ImageEditor docs: https://github.com/wapmorgan/ImageEditor-doc
- ImageEditor class reference (API): http://wapmorgan.github.io/ImageEditor-doc/classes/ImageEditor.html