Skip to content

Identify similar colours

olf edited this page Nov 10, 2024 · 5 revisions

Ideas to identify similar background colours of comics

Output web-RGB colours

grep -R '"color":' plugins/ | tr -d '",:' | tr -s ' ' | cut -f 1,3 -d ' ' | column -tO 2,1 -o ' ' | sed 's# .\+/\([[:alnum:]]\+\)/info.json$# \1#' | sort

Output R, G and B components separately as hex values

grep -R '"color":' plugins/ | tr -d '",:' | tr -s ' ' | cut -f 1,3 -d ' ' | column -tO 2,1 -o ' ' | sed 's# .\+/\([[:alnum:]]\+\)/info.json$# \1#' | sort | sed -e 's/^\(....\)\(..\)/\1 0x\2/' -e 's/^\(..\)\(..\)/\1 0x\2/' -e 's/^\(..\)/0x\1/'

Output R, G and B components separately as decimal values

printf '%d %d %d %s\n' $(grep -R '"color":' plugins/ | tr -d '",:' | tr -s ' ' | cut -f 1,3 -d ' ' | column -tO 2,1 -o ' ' | sed 's# .\+/\([[:alnum:]]\+\)/info.json$# \1#' | sort | sed -e 's/^\(....\)\(..\)/\1 0x\2/' -e 's/^\(..\)\(..\)/\1 0x\2/' -e 's/^\(..\)/0x\1/') | column -t

Generate an image to compare the colour values visually

Notes:

  • $(wc -l outfile.txt) may count a line too much (i.e. the concluding \n aka "newline" character): Use $(($(wc -l outfile.txt)-1) then.
  • If a PNG image is wanted, replace > outimage.ppm by either | pnmtopng > outimage.png or | convert - outimage.png or | ffmpeg -i - outimage.png / > outimage.ppm; ffmpeg -i outimage.ppm outimage.png.

Sorted primarily by R, secondarily by G, thirdly by B values

grep -R '"color":' plugins/ | tr -d '",:' | tr -s ' ' | cut -f 1,3 -d ' ' | column -tO 2,1 -o ' ' | sed 's# .\+/\([[:alnum:]]\+\)/info.json$# \1#' | sort | tee outfile.txt | cut -f 1 -d ' ' | sed -e p -e p -e p -e p -e p -e p -e p | tr -d '\n' | xxd -r -ps | rawtoppm 8 $(wc -l outfile.txt) > outimage.ppm

Sorted primarily by G, secondarily by R, thirdly by B values

grep -R '"color":' plugins/ | tr -d '",:' | tr -s ' ' | cut -f 1,3 -d ' ' | column -tO 2,1 -o ' ' | sed -e 's# .\+/\([[:alnum:]]\+\)/info.json$# \1#' -e 's/^\(..\)\(..\)\(..\) /\2\1\3 /' | sort | tee outfile.txt | cut -f 1 -d ' ' | sed -e p -e p -e p -e p -e p -e p -e p | tr -d '\n' | xxd -r -ps | rawtoppm -grb 8 $(wc -l outfile.txt) > outimage.ppm

Sorted primarily by B, secondarily by G, thirdly by R values

grep -R '"color":' plugins/ | tr -d '",:' | tr -s ' ' | cut -f 1,3 -d ' ' | column -tO 2,1 -o ' ' | sed -e 's# .\+/\([[:alnum:]]\+\)/info.json$# \1#' -e 's/^\(..\)\(..\)\(..\) /\3\2\1 /' | sort | tee outfile.txt | cut -f 1 -d ' ' | sed -e p -e p -e p -e p -e p -e p -e p | tr -d '\n' | xxd -r -ps | rawtoppm -bgr 8 $(wc -l outfile.txt) > outimage.ppm

Other RGB-permutations can be constructed accordingly.

Clone this wiki locally