dotfiles/.local/bin/scripts/transparent

11 lines
481 B
Plaintext
Raw Normal View History

2022-07-06 07:33:08 +00:00
#!/bin/sh -ex
# Turn white (or another color) into transparent for the given images
2022-08-04 21:53:53 +00:00
# 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
2022-07-06 07:33:08 +00:00
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