-
Notifications
You must be signed in to change notification settings - Fork 0
/
imagemagick.php
89 lines (77 loc) · 2.05 KB
/
imagemagick.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
<?php
include_once "./Color.php";
include_once "./ColorNaming.php";
include_once "./ColorDebugger.php";
include_once "./ColorOccurrence.php";
include_once "./ColorCollection.php";
include_once "./ColorImageProcessor.php";
include_once "./functions/ColorMergerFunctions.php";
include_once "./functions/ColorEquivalencyFunctions.php";
include_once "./functions/ColorCollectionFilterFunctions.php";
include_once "./util/db.php";
include_once "./util/density.php";
include_once "./util/colors-to-database.php";
echo "
<style>
html, body {
margin: 0;
padding: 0;
scroll-snap-type: y mandatory;
}
body .image-with-colors {
scroll-snap-align: start;
}
</style>
";
//$colors = new ColorCollection();
//$step = 5;
//
//for ($hue = 0; $hue <= 360; $hue += $step) {
//
// for ($saturation = 0; $saturation <= 1.00001; $saturation += $step / 100) {
//
//// $lightness = 0.75;
//
// for ($lightness = 0; $lightness <= 1.00001; $lightness += $step / 100) {
//
// $color = Color::fromHSL($hue, $saturation, $lightness);
//
//// if (count(ColorNaming::getNames($color)) === 0) $colors->addColors($color);
//
//// if (ColorNaming::isBrown($color)) $colors->addColors($color);
//
// $colors->addColors($color);
//
// }
//
// }
//
//}
//addColorsToDatabase();
//$colors = $colors->head(3000, 3000);
//for ($r = 0; $r <= 255; $r += $step) {
//
// for ($g = 0; $g <= 255; $g += $step) {
//
// for ($b = 0; $b <= 255; $b += $step) {
//
// $color = new Color($r, $g, $b);
//
// if (ColorNaming::isRed($color)) $colors->addColors($color);
//
// }
//
// }
//
//}
//echo ColorDebugger::showColorCollection($colors);
$startTime = microtime(true);
$imagePath = "examples/stressless-consul-chair-ottoman.jpg";
$imageProcessor = ColorImageProcessor::fromURI($imagePath);
$imageSize = $imageProcessor->getImageSize();
$imageColors = $imageProcessor->getPrimaryImageColors();
echo ColorDebugger::showColorCollectionWithImage(
$imagePath,
$imageColors,
$imageSize->x . "x" . $imageSize->y . " image scanned in " . number_format(microtime(true) - $startTime, 2) . " seconds."
);