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.1.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.1-py3-none-any.whl (4.1 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: svgreplicate-0.1.1.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.1.tar.gz
Algorithm Hash digest
SHA256 116dd1686cb2a80baf673e25926ccf1911dcfec19b0b005fa8b427ac0081f938
MD5 44208275bdd2f7e5f2021d826658e379
BLAKE2b-256 b980f687e444720565629298cd952c94f81f739080e293be7e86347711f375c1

See more details on using hashes here.

File details

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

File metadata

  • Download URL: svgreplicate-0.1.1-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.1-py3-none-any.whl
Algorithm Hash digest
SHA256 166563bda7789c99524750402993f4aa1f10ddc177b888debfe4b7c75e9f91cb
MD5 7728b1442b0aced413e8beadb2d3a93e
BLAKE2b-256 7d214f9d2887d35976a45804959f5850437f82a84c23789286cc9a62ff388d58

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