From bee07eedbde73eebcd54d45e799c4682ab97bf50 Mon Sep 17 00:00:00 2001 From: xeruf <27jf@pm.me> Date: Wed, 6 Jul 2022 09:33:08 +0200 Subject: [PATCH] bin/transparent: initial version --- .local/bin/scripts/transparent | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100755 .local/bin/scripts/transparent diff --git a/.local/bin/scripts/transparent b/.local/bin/scripts/transparent new file mode 100755 index 0000000..19ce66a --- /dev/null +++ b/.local/bin/scripts/transparent @@ -0,0 +1,9 @@ +#!/bin/sh -ex +# Turn white (or another color) into transparent for the given images +# TODO https://safe.duckduckgo.com/?q=imagemagick+color+to+alpha&ia=web https://stackoverflow.com/questions/26408022/imagemagick-color-to-alpha-like-the-gimp/27194202#27194202 +case $1 in (-*) color=${1#-};; esac +for arg +do extension="-transparent.${arg##*.}" + case $extension in (*jp*g) extension=".png";; esac + convert "$arg" -transparent ${color:-white} -fuzz 60% "$arg$extension" +done