-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathindex.php
69 lines (57 loc) · 1.59 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
<?php
include_once( 'colorsofimage.class.php' );
$image = isset( $_GET['image'] ) ? $_GET['image'] : null;
function display_colors( $colors ) {
?>
<div style="overflow: hidden">
<?php foreach ( $colors as $color ) : ?>
<?php display_color( $color ) ?>
<?php endforeach; ?>
</div>
<?php
}
function display_color( $color ) {
?>
<div style="width: 20px; float: left; height: 20px; background-color: <?php echo $color ?>"></div>
<?php
}
?>
<html>
<head>
</head>
<body style="background-color: white">
<form>
<input type="text" name="image" />
<button type="submit">Submit</button>
</form>
<?php
if ( $image ) :
$colors_of_image = new ColorsOfImage( $image );
$colors = $colors_of_image->getProminentColors();
?>
<p><img src="<?php echo $image ?>" /></p>
Colors of Image:
<?php display_colors( $colors ); ?>
<p>Background Color</p>
<?php
if ($colors_of_image->getBackgroundColor() != null) {
display_color( $colors_of_image->getBackgroundColor() );
$count = count($colors) + 1;
}
else {
$count = count($colors); ?>
<p>no background(transparent)</p>
<?php } ?>
<br>
<p>number of colors : <?php echo $count; ?></p>
<p style="margin-top: 15px; clear: both">Color Map</p>
<div>
<?php foreach ( $colors_of_image->getColorMap() as $color_from => $color_to ) : ?>
<div style="width: 90px; float: left; height: 25px;">
<?php display_color( $color_from ) ?> <div style="float: left">→</div> <?php display_color( $color_to ) ?>
</div>
<?php endforeach; ?>
</div>
<?php endif; ?>
</body>
</html>