summaryrefslogtreecommitdiffstats
path: root/share/extensions/color_desaturate.py
diff options
context:
space:
mode:
Diffstat (limited to '')
-rwxr-xr-xshare/extensions/color_desaturate.py19
1 files changed, 19 insertions, 0 deletions
diff --git a/share/extensions/color_desaturate.py b/share/extensions/color_desaturate.py
new file mode 100755
index 0000000..1710b1e
--- /dev/null
+++ b/share/extensions/color_desaturate.py
@@ -0,0 +1,19 @@
+#!/usr/bin/env python
+"""Remove colors"""
+
+import inkex
+
+
+class Desaturate(inkex.ColorExtension):
+ """Remove color but maintain intesity"""
+
+ def modify_color(self, name, color):
+ lum = (
+ max(color.red, color.green, color.blue)
+ + min(color.red, color.green, color.blue)
+ ) // 2
+ return inkex.Color((int(round(lum)), int(round(lum)), int(round(lum))))
+
+
+if __name__ == "__main__":
+ Desaturate().run()