Skip to content

Instantly share code, notes, and snippets.

@nikosavola
Created August 26, 2021 10:16
Show Gist options
  • Save nikosavola/7bf676703b205470b87acf06a0627b21 to your computer and use it in GitHub Desktop.
Save nikosavola/7bf676703b205470b87acf06a0627b21 to your computer and use it in GitHub Desktop.
Hex colors to images
# regex for matching hex colors \#[0-9a-f]{6}
url = 'https://singlecolorimage.com/get/'
end = '/200x70'
colors = ['#80a8ff',
'#01ff6b',
'#ff8000',
'#000000',
'#00ffff',
'#ddff00',
'#808000',
'#80ff8d',
'#afff80',
'#91ff00',
'#ffae00',
'#c0c0c0',
'#ff00ff',
'#c080ff',
'#9580ff',
'#ffaaba',
'#800080',
'#500080',
'#004080',
'#800057',
'#0000ff',
'#8086ff',
'#ffc280',
'#ffa080',
'#ff0000',
'#ff9d9d']
colors = list(map(lambda x: x[1:], colors))
urls = [url + color + end for color in colors]
markdown = ['![' + color + ']' + '('+img_url+')' for color, img_url in zip(list(colors), urls)]
for line in markdown:
print(line)

Get Markdown embeddable images from hex color tags.

Example output:

80a8ff 01ff6b ff8000 000000 00ffff ddff00 808000 80ff8d afff80 91ff00 ffae00 c0c0c0 ff00ff c080ff 9580ff ffaaba 800080 500080 004080 800057 0000ff 8086ff ffc280 ffa080 ff0000 ff9d9d

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment