summaryrefslogtreecommitdiff
path: root/index.php
diff options
context:
space:
mode:
Diffstat (limited to 'index.php')
-rw-r--r--index.php29
1 files changed, 28 insertions, 1 deletions
diff --git a/index.php b/index.php
index 4c1ee55..3909f9b 100644
--- a/index.php
+++ b/index.php
@@ -112,7 +112,33 @@ function domcolor_mode($img, $flt)
return false;
}
-$domalgos = array('mean', 'mode');
+
+function domcolor_custom($img, $flt)
+{
+ $color = $_POST['customcolor'];
+
+ /* Remove prefixing '#' if present. */
+ if ($color[0] == '#') $color = substr($color, 1);
+
+ if (strlen($color) == 6) {
+ /* Handle rrggbb format. */
+ $r = $color[0].$color[1];
+ $g = $color[2].$color[3];
+ $b = $color[4].$color[5];
+ } elseif (strlen($color) == 3) {
+ /* Handle rgb format. */
+ $r = $color[0].$color[0];
+ $g = $color[1].$color[1];
+ $b = $color[2].$color[2];
+ } else {
+ /* Unknown format. */
+ return false;
+ }
+
+ return array(hexdec($r), hexdec($g), hexdec($b));
+}
+
+$domalgos = array('mean', 'mode', 'custom');
$colfilters = array('none', 'pure', 'grey', 'grey5');
function extract_dominant_color($svg, $algo = 'average', $filter = 'grey')
@@ -374,6 +400,7 @@ echo '<?xml version="1.0" encoding="utf-8" ?>';
<legend>Algorithm for dominant color extraction</legend>
<label><input type="radio" name="domalgo" value="mean" />Mean / Average</label>
<label><input type="radio" name="domalgo" value="mode" checked="true" />Mode</label>
+ <label><input type="radio" name="domalgo" value="custom" checked="true" />Custom: <input type="text" name="customcolor" /></label>
</fieldset>
<fieldset>
<legend>Colors to ignore</legend>