Doubled resolution of ANSI-art screenshots, by using FG and BG colours. The drawback is that there are less color choices for the background color.

This commit is contained in:
Georges Dupéron 2018-06-29 00:48:38 +02:00
parent 70a1d44c6a
commit be6bc729f6

View File

@ -7,6 +7,10 @@ mini_png="$(tempfile --suffix=".png")"
colors_gif="$(tempfile --suffix=".gif")"
indexed_gif="$(tempfile --suffix=".gif")"
indexed_pgm="$(tempfile --suffix=".pgm")"
odd_lines="$(tempfile --suffix=".odd")"
even_lines="$(tempfile --suffix=".even")"
odd_lines_px="$(tempfile --suffix=".odd.px")"
even_lines_px="$(tempfile --suffix=".even.px")"
colors=(78,78,78 255,108,96 0,170,0 288,288,182 150,203,254 255,115,253 85,255,255 238,238,238 124,124,124 255,155,147 177,253,121 255,255,145 181,220,254 255,156,254 85,255,255 255,255,255)
args=()
@ -25,8 +29,15 @@ done
&& convert "${indexed_gif}" "${indexed_pgm}" \
&& tail -n +4 "${indexed_pgm}" \
| hexdump -Cv \
| sed -n -r -e 's/^[0-9a-f]* (([0-9a-f]{2} ){8}) (([0-9a-f]{2} ){7}[0-9a-f]{2}).*$/\1\3/p' \
| sed -n -r -e 's/^[0-9a-f]* (([0-9a-f]{2} ?){1,16}).*$/\1/p' \
| tr '\n' ' ' \
| sed -r -e 's/ +/ /g' \
| fold -w $((width*3)) \
| sed -r -e 's/([01])([0-7]) /[\1;3\2m█/g' \
| awk "{ if (NR % 2 == 0) print > \"$even_lines\"; else print > \"$odd_lines\"; }"
cat "$odd_lines" | sed -e 's/ $//' | tr ' ' '\n' > "$odd_lines_px"
cat "$even_lines" | sed -e 's/ $//' | tr ' ' '\n' > "$even_lines_px"
paste "$odd_lines_px" "$even_lines_px" \
| tr '\t\n' ' ' \
| fold -w $((width*6)) \
| sed -r -e 's/([01])([0-7]) ([01])([0-7]) /[\1;3\2;4\4m▀/g' -e 's/$//' \
| if test "$CI" = "true" -a "$TRAVIS" = "true"; then while read ab; do echo "$ab"; sleep 0.05; done; else cat; echo; fi