https://github.com/dneustadt/average-color-matrix
Generates a matrix in desired resolution of average colors of an image
https://github.com/dneustadt/average-color-matrix
average colors hex image matrix rgb svg
Last synced: 10 months ago
JSON representation
Generates a matrix in desired resolution of average colors of an image
- Host: GitHub
- URL: https://github.com/dneustadt/average-color-matrix
- Owner: dneustadt
- License: mit
- Created: 2018-01-13T19:19:20.000Z (about 8 years ago)
- Default Branch: master
- Last Pushed: 2018-01-15T00:40:58.000Z (about 8 years ago)
- Last Synced: 2024-12-14T22:08:39.204Z (about 1 year ago)
- Topics: average, colors, hex, image, matrix, rgb, svg
- Language: PHP
- Size: 54.7 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
README
AverageColorMatrix
=====
Generates a matrix in desired resolution of average colors of an image.
Can also output result as SVG Markup.
## Demo
[See here](https://htmlpreview.github.io/?https://github.com/dneustadt/average-color-matrix/blob/master/demo/demo.html)
## Usage
Create an Instance of `AverageColorMatrix` passing the absolute path to the image.
Call `get` method of said instance with the x, y resolution. The third
argument expects a boolean (default: `false`). If `true` the output
will be SVG markup.
Returns a nested array of rows and columns with RGB and hex values.
Alternatively returns SVG markup ready to use.
## Example
```php
$matrix = new \AverageColorMatrix\AverageColorMatrix(
__DIR__ . DIRECTORY_SEPARATOR . $filename
);
$matrix->get(4, 4);
```
Result:
```
array(3) {
["y_percent"]=>
float(25)
["x_percent"]=>
float(25)
["tiles"]=>
array(4) {
[0]=>
array(4) {
[0]=>
array(4) {
["r"]=>
int(214)
["g"]=>
int(215)
["b"]=>
int(220)
["hex"]=>
string(7) "#d6d7dc"
}
[...]
}
[...]
}
}
```
## License
MIT