Skip to main content

Tool for batch modifying and replicating SVG-files

Project description

SVGReplicate

Tool for batch modifying and replicating SVG files.

Installation

Install from PyPI by running pip install svgreplicate.

Usage

Create an SVG file, either by hand or with your favorite vector graphics tool, like InkScape:

<svg
    width="210mm"
    height="297mm" 
    id="svg" 
    version="1.1"
    xmlns="http://www.w3.org/2000/svg" >
    <g id="group1">
        <ellipse
            style="opacity:1;fill:#009bff"
            id="ellipse1"
            cx="0.0"
            cy="0.0"
            rx="10.0"
            ry="10.0" />
        <g id="group2" />
    <text id="text1">
        <tspan>First text</tspan>
        <tspan>Second text 
            <tspan>Nested text</tspan> 
        </tspan>
    </text>
    </g>
</svg>

Next, create a json with the replicas you want:

[
    {
        "filename": "example/replica1.svg", 
        "modifications": [
        	{"id": "ellipse1", "style": {"fill": "#000000", "display": "none"}},
        	{"id": "group2", "style": {"display": "none"}},
        	{"id": "text1", "text": "Hello, world!"}
        ]
    },
    {
        "filename": "example/replica2.svg",
        "modifications": [
                {"id": "ellipse1", "style": {"fill": "#ffffff", "display": "none"}},
                {"id": "group2", "style": {"display": "none"}},
                {"id": "text1", "text": "Here's Johnny!"}
        ]
    }
]

And finally, run the script:

svgreplicate --filename path-to-svg-template.svg --replicas path-to-replicas-config.json 

You now have 2 files in the example folder, based on the template, with the specified modifications.

Backlog

In future, I'd like to add at least the functionality for automatically rendering to PNG.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

svgreplicate-0.1.0.tar.gz (3.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

svgreplicate-0.1.0-py3-none-any.whl (4.1 kB view details)

Uploaded Python 3

File details

Details for the file svgreplicate-0.1.0.tar.gz.

File metadata

  • Download URL: svgreplicate-0.1.0.tar.gz
  • Upload date:
  • Size: 3.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.1.12 CPython/3.10.2 Linux/5.13.0-35-generic

File hashes

Hashes for svgreplicate-0.1.0.tar.gz
Algorithm Hash digest
SHA256 c02045c13ba0e25c8f6ebda196ce1dd684949b71288b35108183c7625397f098
MD5 8e71f3c162cdfd1182ac479b56acee0b
BLAKE2b-256 1c326d515f3595b867f293de30a2f78cecafeea8fab7f2eead7c2695e623d066

See more details on using hashes here.

File details

Details for the file svgreplicate-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: svgreplicate-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 4.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.1.12 CPython/3.10.2 Linux/5.13.0-35-generic

File hashes

Hashes for svgreplicate-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 45ae7d464bb8c3d0f50e2eb6030fe31640d7c8a9e2057b064daf032d206c3660
MD5 83a001f967b19533a8ac87cc670c5ed6
BLAKE2b-256 95460e8f12a340f66058b5a53078a37074abfeb65a6df4840c452a2387a9c3c3

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page