Palleter
Forum rules
Your own work only.
Your own work only.
Re: Palleter
^ OK, got that, thanks. So, it looks like it just outputs the color palette info into the console, right? What's the best way to get that info from the console to a new entry in the "console_colors" directory?
Re: Palleter
Code: Select all
./palleterx /path/to/image > /path/to/xcolors_file
Re: Palleter
I do this
I do it this way to add in bg and fg colors, or whatever
Ahh, I see pids chimed in already.
Code: Select all
./palleterX /path/to/image > /path/to/console_colors/newscheme && $editor /path/to/console_colors/newscheme
Ahh, I see pids chimed in already.
Work hard; Complain less
Re: Palleter
Excellent, thanks gentlemen!
Re: Palleter
Sorry; I didn't wait long enough for you to answer -- your answer is better anyway.dkeg wrote:Ahh, I see pids chimed in already.
Re: Palleter
Both work great, thanks. The results of my first...
I'm calling it 'nightscape':
I'm calling it 'nightscape':
Code: Select all
!!!! nightscape !!!!
*background:#111111
*foreground:#d3d3d3
*fading:10
*fadeColor:#111111
*transparent:0
*shading:70
*color0: #0A0C11
*color1: #111526
*color2: #21221F
*color3: #2D3747
*color4: #2F2D2F
*color5: #354C54
*color6: #374536
*color7: #49362B
*color8: #575F5B
*color9: #5C4C31
*color10: #637D7F
*color11: #6F9FCE
*color12: #708F94
*color13: #946738
*color14: #B4C4B9
*color15: #BD9E5A
Re: Palleter
^ Done!
Re: Palleter
My bash is too weak, so I added some changes in python to suit my setup better. The changes are:
- The brightest color is labeled as foreground
- The darkest as background
- The histogram from imagemagick is tweaked to produce more 'drastic' colors with the use of the -level parameter
The script used upon this image:
Yields:
Which colorized looks like this (disregard the background color):
- The brightest color is labeled as foreground
- The darkest as background
- The histogram from imagemagick is tweaked to produce more 'drastic' colors with the use of the -level parameter
Code: Select all
#!/usr/bin/env python2.7
import re
import sys
import operator
import commands
histogram = commands.getoutput('convert '+sys.argv[1]+' -colors 16 -level 10% -format "%c" histogram:info: | sort -nr').split('\n')
colors = list()
outputColors = dict()
outputSpecial = dict()
for line in histogram:
#extract the hex string
hex = re.search("\((.+?)\).(\#\S{6})",line).group(2)
#regex, strip, and put R-G-B into an array
rgb = re.search("\((.+?)\).(\#\S{6})",line).group(1).split(',')
rgb = map(str.strip, rgb)
rgb = map(int, rgb)
# approximated luma calculation
luma = (rgb[0]+rgb[0]+rgb[1]+rgb[2]+rgb[2]+rgb[2])/6
colors.append({'luma':luma, 'hex':hex})
# get the darkest and brightest and remove them from the list
seq = [c['luma'] for c in colors]
maxLuma = max(seq)
minLuma = min(seq)
for i,c in enumerate(colors):
if c['luma'] == minLuma:
outputSpecial["background"]= c['hex']
elif c['luma'] == maxLuma:
outputSpecial["foreground"] = c['hex']
else:
outputColors["color"+str(i)] = c['hex']
print '\n'.join("*.%s: %s" % (key,val) for (key,val) in outputSpecial.iteritems())
for key in sorted(outputColors.iterkeys()):
print "*.%s: %s" % (key, outputColors[key])
Yields:
Code: Select all
*.foreground: #FFFFFF
*.background: #000000
*.color0: #6D6D5F
*.color1: #E2E06E
*.color10: #382FFD
*.color11: #3B3200
*.color12: #E2E2E2
*.color13: #DCDAAF
*.color14: #D5A818
*.color15: #17B1ED
*.color2: #989898
*.color5: #3D3D3D
*.color6: #1DAB1C
*.color7: #A8A15D
*.color8: #1F1510
*.color9: #C14809
Re: Palleter
Theres another interesting take on this task. If you sort the histogram outbut by the first column, you will get the most popular/representative color of the image.
I'm thinking about the most universal way of extracting usable palletes. Something like:
- Get histogram sorted by popularity
- Grap and pop darkest and lightest
- Sort the rest by hue (?)
Now that I've written these steps down, not sure what's the point of the sorting in the first place...
I'm thinking about the most universal way of extracting usable palletes. Something like:
- Get histogram sorted by popularity
- Grap and pop darkest and lightest
- Sort the rest by hue (?)
Now that I've written these steps down, not sure what's the point of the sorting in the first place...
Re: Palleter
nice, great work man. you could've of course taken the opportunity to brush up your bash, but who cares ;)
All statements are true in some sense, false in some sense, meaningless in some sense, true and false in some sense, true and meaningless in some sense, false and meaningless in some sense, and true and false and meaningless in some sense.
- doubledutch
- killall X
- Posts: 163
- Joined: Sun Aug 10, 2014 1:25 pm
Re: Palleter
Now write it in objective-c and get app store famous. Beautiful script.