Is there an 'easy' way to replace, for example, all nuances of yellow colors in an image with the 'same' nuances of red?
f ex (and this is probably not correct)
yellow :fff0004f fff7476f
red :ff0004ff ff7476ff
I know there could be another forum for this, and if you know of any other forum that deals with vector graphics in general, or another program, or small script or something, please let me know.
command-lineish stuff are welcome, since the next step is to batch process a lot of files.
Lars
replacing colours
Re: replacing colours
Open your svg file in a text editor and simply do a search and replace for those color codes.
-
- Posts: 7
- Joined: Mon Nov 28, 2011 9:35 am
Re: replacing colours
llogg wrote:Open your svg file in a text editor and simply do a search and replace for those color codes.
I have to do it in around 3000 images thou, so that's not an option, I need something automated.
Re: replacing colours
Are you on Windows? Or Linux/MacOS?
If it's the latter, I suggest looking into "sed" (or "awk" for even more power) for doing command-like search-and-replace operations on a whole load of files. If you're on Windows the you can install Cygwin in order to get a Unixy command line with sed.
*EDIT*
From one of your other posts it looks like you're already familiar with sed. If that won't do what you want, can you explain a little more about what you need.
If it's the latter, I suggest looking into "sed" (or "awk" for even more power) for doing command-like search-and-replace operations on a whole load of files. If you're on Windows the you can install Cygwin in order to get a Unixy command line with sed.
*EDIT*
From one of your other posts it looks like you're already familiar with sed. If that won't do what you want, can you explain a little more about what you need.
Re: replacing colours
Well, there's an extension, under Extensions > Color > Replace color. But obviously in just one file at a time...
Also, I believe Inkscape comes with it's own version of Python (in Inkscape\python directory). So you might get lucky there as Python has a lot of power. So the "easy" way would be to create a script like this (easier because you have to copy-paste ):
You save that file into Inkscape\python with a "py" extension, say "replace.py", and then double click the python.exe file and write "import replace" and that would be it.
Hope it helps.
EDIT: btw, you might want to skip the last "ff" (alpha channel) as it seems that it's not stored in the way I believed, so you would replace the RGB part only.
Also, I believe Inkscape comes with it's own version of Python (in Inkscape\python directory). So you might get lucky there as Python has a lot of power. So the "easy" way would be to create a script like this (easier because you have to copy-paste ):
Code: Select all
import glob
colors = [{'color': '#0000ffff', 'replace': '#0000ff00'},
{'color': '#ffffffff', 'replace': '#00000000'}
]
for f in glob.glob('d:/MyFiles/*.svg'):
print f
fh = open(f, 'r+')
data = fh.read()
for c in colors:
data = data.replace(c['color'], c['replace'])
fh.seek(0);
fh.write(data)
fh.close()
You save that file into Inkscape\python with a "py" extension, say "replace.py", and then double click the python.exe file and write "import replace" and that would be it.
Hope it helps.
EDIT: btw, you might want to skip the last "ff" (alpha channel) as it seems that it's not stored in the way I believed, so you would replace the RGB part only.