This repository has been archived by the owner on Oct 12, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 10
/
index.php
72 lines (62 loc) · 2.19 KB
/
index.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
<?php
require_once("ColorPalette.php");
?>
<html>
<head>
<title>PHP Image to Color Palette Examples</title>
</head>
<body>
<h1>PHP Image to Color Palette Examples</h1>
<h2>Local Image</h2>
<?php
$localPalette = ColorPalette::GenerateFromLocalImage("MuppetsOfSesameStreet.jpg");
?>
<img src="MuppetsOfSesameStreet.jpg" width="300px">
<br />
<?php
printPalette($localPalette);
?>
<h2>Remote Image</h2>
<?php
$url = "http://upload.wikimedia.org/wikipedia/en/d/dd/Muppets_take_manhattan.jpg";
$remotePalette = ColorPalette::GenerateFromUrl($url);
?>
<br />
<img src="<?php print $url?>" height="150px">
<?php
printPalette($remotePalette);
?>
<h2>Remote Set of Images</h2>
<?php
$urls = array(
"http://images1.wikia.nocookie.net/__cb20110228193806/muppet/images/thumb/1/12/Muppetmovieposter.jpg/200px-Muppetmovieposter.jpg",
"http://images3.wikia.nocookie.net/__cb20090709025947/muppet/images/thumb/c/ca/GMCposter.jpg/200px-GMCposter.jpg",
"http://images2.wikia.nocookie.net/__cb20090709030020/muppet/images/thumb/a/a4/Poster.manhattan.jpg/200px-Poster.manhattan.jpg",
"http://images3.wikia.nocookie.net/__cb20090709014824/muppet/images/thumb/b/be/Mxcposter.jpg/200px-Mxcposter.jpg",
"http://images2.wikia.nocookie.net/__cb20090709030057/muppet/images/thumb/7/74/Mtiposter.jpg/200px-Mtiposter.jpg",
"http://images3.wikia.nocookie.net/__cb20090709030127/muppet/images/thumb/b/bc/Mfsposter.jpg/200px-Mfsposter.jpg",
"http://images1.wikia.nocookie.net/__cb20060125061949/muppet/images/thumb/5/56/IAVMMCMDVD.JPG/200px-IAVMMCMDVD.JPG",
"http://images2.wikia.nocookie.net/__cb20060318061146/muppet/images/thumb/9/9d/Ozposter.jpg/200px-Ozposter.jpg",
"http://images3.wikia.nocookie.net/__cb20110727202911/muppet/images/thumb/9/99/TheMuppets1Sheet.jpg/200px-TheMuppets1Sheet.jpg",
);
$remotePalette = ColorPalette::GenerateFromUrls($urls);
foreach($urls as $url){
?>
<img src="<?php print $url?>" height="150px">
<?php
}
?>
<br />
<?php
printPalette($remotePalette);
?>
</body>
</html>
<?php
function printPalette($palette){
foreach(array_slice(array_keys($palette),0,10) as $color){
?> <div style="background-color:<?php print $color?>;display:inline-block;width:50px;height:50px;"><?=$color?></div>
<?php
}
}
?>