https://github.com/deanblackborough/random-grab-bag
A random grab bag of utility classes that have no fixed abode yet.
https://github.com/deanblackborough/random-grab-bag
image-crop image-resize
Last synced: about 2 months ago
JSON representation
A random grab bag of utility classes that have no fixed abode yet.
- Host: GitHub
- URL: https://github.com/deanblackborough/random-grab-bag
- Owner: deanblackborough
- License: mit
- Created: 2017-06-01T08:44:22.000Z (almost 8 years ago)
- Default Branch: master
- Last Pushed: 2018-01-02T00:47:30.000Z (over 7 years ago)
- Last Synced: 2025-02-14T19:37:28.209Z (3 months ago)
- Topics: image-crop, image-resize
- Language: PHP
- Homepage: http://transmute-coffee.com/
- Size: 273 KB
- Stars: 1
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
[](https://packagist.org/packages/deanblackborough/random-grab-bag)
[](https://github.com/deanblackborough/random-grab-bag/blob/master/LICENSE)
[](https://php.net/)# Random grab bag
*Catch all library for utility classes.*
## Description
A random grab bag of utility classes that have no fixed abode yet.
## Installation
The easiest way to use any of these classes is via composer. ```composer require deanblackborough/random-grab-bag```,
alternatively include the classes in src/ in your library.## The classes
### Image Resize
You can use the resize class via the API or directly if you want or need a little more control over the
output and options.#### API
```
$resizer = new DBlackborough\GrabBag\ImageResize($format);$resizer->resizeTo(
$width,
$height,
$maintain_aspect = true,
$canvas_color = [ 'r' => 0, 'g' => 0, 'b' => 0]
)
->source($source_file, $source_path = '')
->target($target_file, $target_path = '');
```#### Direct
```
$resizer = new DBlackborough\GrabBag\ImageResize\Jpeg();$resizer->setOptions(
$width,
$height,
$maintain_aspect = true,
$canvas_color = [ 'r' => 0, 'g' => 0, 'b' => 0]
)
->loadImage($source_file, $source_path = '')
->resizeSource()
->createCopy()
->save();
```#### Public methods
I've listed the methods, their params and the return type. If it isn't obvious what a method
does I have done a bad job of naming it, if so, please let me know.* createCopy() : `AbstractResize`
* getInfo() : `array`
* loadImage(`string` $file, `string` $path = '') : `AbstractResize`
* resizeSource() : `AbstractResize`
* save() : `AbstractResize`
* setCanvasColor(`array` $canvas_color) : `AbstractResize`
* setFileName(`string` $filename) : `AbstractResize`
* setHeight(`int` $height) : `AbstractResize`
* setOptions(`int` $width, `int` $height, `int` $quality, `bool` $maintain_aspect = true, `array` $canvas_color = array('r' => 255, 'g' => 255, 'b' => 255)) : `AbstractResize`
* setPath($path) : `AbstractResize`
* setWidth(int $width) : `AbstractResize`