Last active
July 22, 2024 01:13
-
-
Save e12e/7990e56f48ceff5506d7 to your computer and use it in GitHub Desktop.
Colors hack
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/sh | |
image="${1}" | |
sz="100px" | |
for space in sRGB RGB HSV LAB | |
do | |
# I think it should be possible to do this without | |
# writing | |
# tiff-images to disk in-between -- but having a | |
# look at the | |
# resulting images next to the original is | |
# actually quite nice | |
# gives some idea of the differences | |
# colorspace makes: | |
convert "${image}" -quantize "${space}" +dither -colors 4 "${image}_${space}.tiff" | |
echo "Histogram in ${space} colorspace:" | |
convert "${image}_${space}.tiff" -format %c histogram:info:- | tee ${space}.txt | |
echo | |
done | |
colortable() | |
{ | |
my_space="${1}" | |
echo "${my_space}:" | |
echo '<table><tr>' | |
sed -nre 's/.*(#[0-9A-F]{6}) .*/\1/p' "${my_space}.txt" | while read color | |
do | |
echo "<td style='width:${sz};height:${sz};background:${color}'> </td>" | |
done | |
echo '</tr></table>' | |
} | |
htmlhead() | |
{ | |
cat > index.html <<eof | |
<html> | |
<pre> | |
<img src="./${image}" /> | |
eof | |
} | |
middle() | |
{ | |
for space in sRGB RGB HSV LAB | |
do | |
colortable "${space}" >> index.html | |
done | |
} | |
htmlepiloge() | |
{ | |
cat >> index.html <<eof | |
</pre> | |
</html> | |
eof | |
} | |
htmlhead | |
middle | |
htmlepiloge |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<html> | |
<style> | |
body { | |
background: black; | |
color: white; | |
} | |
td { | |
width: 100px; | |
height: 100px; | |
} | |
</style> | |
<pre> | |
<img src="https://gist.githubusercontent.com/e12e/7990e56f48ceff5506d7/raw/e9f5bd9ac442637d845aebb67a0a4f8b7658ec3a/akira.jpg" /> | |
sRGB: | |
<table><tr> | |
</tr></table> | |
RGB: | |
<table><tr> | |
<td style='background:#2D2833'> </td> | |
<td style='background:#5D5664'> </td> | |
<td style='background:#8B777C'> </td> | |
<td style='background:#DA7D4A'> </td> | |
</tr></table> | |
HSV: | |
<table><tr> | |
<td style='background:#1E0D33'> </td> | |
<td style='background:#383450'> </td> | |
<td style='background:#3C1F0A'> </td> | |
<td style='background:#4E9B57'> </td> | |
</tr></table> | |
LAB: | |
<table><tr> | |
<td style='background:#2A293C'> </td> | |
<td style='background:#334857'> </td> | |
<td style='background:#58211B'> </td> | |
<td style='background:#977559'> </td> | |
</tr></table> | |
</pre> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment