This repository was archived by the owner on Jan 3, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 84
Expand file tree
/
Copy pathtest.php
More file actions
58 lines (47 loc) · 1.31 KB
/
test.php
File metadata and controls
58 lines (47 loc) · 1.31 KB
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
<?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>
<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 display_color( $colors_of_image->getBackgroundColor() ) ?>
<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>