Polotno application you can replace colors in SVG images. Let me tell you how it works.
In order to replace colors in SVG we should:
- Parse SVG image file
- Find all used colors in the image
- Replace required colors with different values
- Serialize data back into SVG image
If you have an URL path to SVG image we need to download it and then parse it to get access to all elements:
When we have access to the DOM of SVG image we can inspect all its elements and find elements that has any color.
Also take a look into https://www.npmjs.com/package/get-svg-colors-browser for that task.
As soon as we have all colors used in the image, we can show them in UI and ask a user to change these colors. All changes we will save in a special map object.