-
Notifications
You must be signed in to change notification settings - Fork 2
/
make-magic-wall.spell
executable file
·53 lines (46 loc) · 1.1 KB
/
make-magic-wall.spell
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
#!/usr/bin/env bash
# make a small wallpaper big by surrouding with a solid color. Inspired by: https://github.com/chrisJuresh/paperWiz
if [[ $1 = "" ]]; then
cat <<EOF
Usage: $0 filename [new-filename]
EOF
exit
fi
case "$1" in
http*)
original=$(mktemp)
wget "$1" -O "$original"
if [[ "$2" ]]; then
new="$2"
else
read -r -p 'output file name? ' new
fi
;;
*)
original=$1
bn=$(basename "$1")
new="${2:-${bn%.*}-magic.${bn#*.}}"
;;
esac
[[ "${maincolor:=$C}" ]] || maincolor=$(
convert "$original" \
-define histogram:unique-colors=true \
-format %c \
histogram:info:- |
sort -n |
sed '$!d' |
cut -d'#' -f2 |
cut -c1-6
)
echo "main color is: #$maincolor" | {
if hash color_picker; then color_picker -f; else cat ; fi;
}
res=2560x1440
solid_color_wall=$(mktemp).png
convert -size $res xc:"#$maincolor" "$solid_color_wall"
magick composite \
-type TrueColor \
-gravity center \
"$original" \
"$solid_color_wall" \
"$new"