https://github.com/yjg30737/svghelper
Set svg color with Python
https://github.com/yjg30737/svghelper
elementtree python python-svg python3 python37 svg svg-color xml
Last synced: 4 months ago
JSON representation
Set svg color with Python
- Host: GitHub
- URL: https://github.com/yjg30737/svghelper
- Owner: yjg30737
- License: mit
- Created: 2022-04-18T06:49:07.000Z (about 4 years ago)
- Default Branch: main
- Last Pushed: 2022-05-24T23:39:33.000Z (about 4 years ago)
- Last Synced: 2025-10-06T22:34:37.153Z (8 months ago)
- Topics: elementtree, python, python-svg, python3, python37, svg, svg-color, xml
- Language: Python
- Homepage:
- Size: 24.4 KB
- Stars: 3
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# svghelper
Python SVG helper. set/replace svg color, etc.
## Install
`python -m pip install svghelper`
## Method Overview
* `set_color(input_file: str, output_file: str, color: str)` - set the color of a svg file. `input_file` is source, `output_file` is result. `color` argument should be 6 digits string color like `#FF0000`.
* `set_files_color(input_dir: str, output_dir: str, output_color: str)` - set the color of svg files in the `input_dir`.
* `replace_color(input_file: str, output_file: str, input_color: str, output_color: str)` - replace the color.
* `replace_files_color(input_dir: str, output_dir: str, input_color: str, output_color: str)` - replace svg files' color.
* `set_comp_color(input_file: str, output_file: str)` - set complementary color.
* `set_files_comp_color(input_dir: str, output_dir: str)` - set svg files' complementary color
## Included Package
* colorgetter
## Example
### Code Sample
```python
import svghelper
# Copy capture.svg as capture2.svg and change the major color of it to #FF0000(red)
svghelper.set_color('capture.svg', 'capture2.svg', '#FF0000')
```
### Result
#### Before

#### After
