Fast version of this page
** No demo connections **
Demonstration Target: Demo. robots.design(tm) will run on a b2evolution blog so you can see it. When you submit an image, the colors will be applied to the blog skin. Your image will be deleted after the colors are extracted. Be sure to click Go. Additional demo: X-Cart skin1
2. Identify colors in target CSS files
These commands recursively read all the CSS files and extract the color attributes. To use them, copy the text into a text file, set the permissions to allow execution and run it, or just paste them on the command line. Paste the results in the textarea below.
The colors in the textarea are those of the demo, if you would like to skin your own application, you must paste the colors from it into the textarea.
Three different command sets are offered:
Searches for color
May be good for searching HTML font tags, as well as CSS.
grep -hr color *.css | sed "s/.*color.*:\ *\"\?\([^\"|^\;|^\!]*\)\(.*\)/color:\1/" | grep ":" > raw.colors
sort raw.colors | uniq
Searches for color and background (without -);
Good for CSS. Should find all color, background, and border settings
grep -ihr color *.css | sed "s/.*color.*:\ *\"\?\([^\"|^\;|^\!]*\)\(.*\)/color:\1;/" | grep ";" > 1.colors
grep -ihr "background[^\-]" *.css | sed "s/.*background.*:\ *\"\?\([^\"|^\;|^\!|\S]*\)\(.*\)/color:\1;/" | grep ";" >> 1.colors
grep -ihr "border[^\-]" *.css | sed "s/.*border.*:\ *\"\?\([^\"|^\;|^\!|\S]*\)\(.*\)/color:\1;/" | grep ";" >> 1.colors
grep -v url 1.colors > 2.colors
grep -v "\/\*" 2.colors > 3.colors
sort 3.colors | uniq > 4.colors
more 4.colors
Searches for colon/space hex code
Good for any file with hex color codes. This is what was used for the demo.
grep -Ghir "[:\ ]#\([0-9a-f]\{3,6\}\)" *.css | sed "s/[^#]*\([^\ |^\"|^\;|^\!]*\)\(.*\)/color:\1/" > raw.colors
sort raw.colors | uniq
3. Generate the sed commands
The sed commands listed below will modify your CSS files. If there are no sed commands, the image or CSS colors haven't been submitted. Be very careful, and be sure you have a backup. They will substitute the colors from step 1 for the colors submitted in step 2. To use it, copy the text into a text file, set the permissions to allow execution and
run it.
Two mappings are offered, view the maps below to decide which is a better match for your application, and use the corresponding sed co
mmands. Interpret the mapping text as follows: first code is the color from the application CSS, second code is from the image. Demo is from the second map.
4. Update the images
The following bash script will deliver an HTML page listing the images and their attributes. Demo
This is a very powerful utility which reads an image and ultimately generates the sed commands to modify existing CSS files to reflect
the colors of that image.
Requisite skills and access: Basic LAMP, SSH access More Information.
User assumes all risk for use of this page and its output.
Contact bgamrat at the domain for information. Comments/suggestions welcome.
Copyright © 2008 Betsy Gamrat. All Rights Reserved.
Credits/Resources
This code uses elements from these URLs