-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathcolours.py
36 lines (33 loc) · 934 Bytes
/
colours.py
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
import os
#
# colour name, and imagemagick colour name
colours = {
'red' : 'red',
'crimson' : 'crimson',
'pink' : 'DeepPink',
'purple' : 'purple',
'indigo' : 'indigo',
'blue' : 'blue',
'navy' : 'navy',
'turquoise' : 'turquoise1',
'teal' : 'teal',
'lime' : 'lime',
'yellow' : 'yellow',
'orange' : 'orange',
}
#
# list all the files in the current directory
current_dir = os.getcwd( )
files = os.listdir( current_dir )
#
# run through the file list
for fname in files:
# for all the png's
if '.png' in fname:
# get the file name
stripped_name = fname[ :fname.rfind( '.' ) ]
# convert to a new colour and save
for colour, magickcolour in colours.iteritems( ):
colour_name = '%s_%s.png' % ( stripped_name, colour)
os.system( 'convert %s +level-colors %s, %s'
% ( fname, magickcolour, colour_name ) )