Skip to main content

Convert PSD file to SVG file

Project description

PSD to SVG converter based on psd-tools2 and svgwrite.

PyPI Version Build Status

Install

Use pip to install:

pip install psd2svg

To use AWS S3 storage backend:

pip install psd2svg[s3]

or:

pip install boto3

To use HDFS storage backend:

pip install psd2svg[hdfs,kerberos]

Usage

The package comes with a command-line tool:

psd2svg input.psd output.svg

When the output path is a directory, or omitted, the tool infers the output name from the input:

psd2svg input.psd output/  # => output/input.svg
psd2svg input.psd          # => input.svg

When --export-resource flag is specified, all png resources are exported to the path specified by --resource-prefix:

psd2svg input.psd output.svg --export-resource
# => output.svg, xxx1.png, ...

psd2svg input.psd output/ --export-resource
# => output/input.svg, output/xxx1.png, ...

psd2svg input.psd output/ --export-resource --resource-prefix=resources/
# => output/input.svg, output/resources/xxx1.png, ...

psd2svg input.psd svg/ --export-resource --resource-prefix=../png/
# => svg/input.svg, png/xxx1.png, ...

To render text in vector stroke:

psd2svg input.psd output/ --text-mode text

The tool can specify URL instead of file path (S3 requires boto3):

psd2svg http://example.com/input.psd
psd2svg s3://bucketname/path/to/input.psd s3://bucketname/path/to/output/

API

The package contains high-level conversion function psd2svg:

from psd2svg import psd2svg

# File IO.
psd2svg('path/to/input.psd', 'path/to/output/')

# Stream IO.
with open('input.psd', 'rb') as fi:
    with open('output.svg', 'w') as fo:
        psd2svg(fi, fo)

# psd_tools IO.
from psd_tools import PSDImage
psd = PSDImage.load('path/to/input.psd')
svg = psd2svg(psd)
print(svg)

# Additionally, individual layers can be rendered.
layer_svg = psd2svg(psd.layers[3])
print(layer_svg)

Test

Invoke tox:

tox

Publish

Execute the following command:

make publish

Notes

  • SVG 1.1 does not cover all the blending modes in Photoshop (e.g., linear-dodge)

  • Filter effects are approximation. Some effects are not implemented.

  • Most of adjustments layers are not implemented.

  • Smart object filters are not implemented.

  • Browser support: SVG rendering quality greatly differs depending on the browser. Chrome tends to be the best quality.

  • APIs of this tool is NOT thread-safe.

  • To use HDFS storage backend, Python 2.7 environment is needed and should be Kerberos-enabled and only read access is available.

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

psd2svg-0.1.1a1.tar.gz (20.1 kB view details)

Uploaded Source

Built Distribution

psd2svg-0.1.1a1-py2.py3-none-any.whl (25.9 kB view details)

Uploaded Python 2 Python 3

File details

Details for the file psd2svg-0.1.1a1.tar.gz.

File metadata

  • Download URL: psd2svg-0.1.1a1.tar.gz
  • Upload date:
  • Size: 20.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for psd2svg-0.1.1a1.tar.gz
Algorithm Hash digest
SHA256 8deee9be8a1e28effe279f41a7a077f27fb0b8b9cc25d99a5682c74551a07673
MD5 5121d9d8d96e51ada785ed608deb7bfc
BLAKE2b-256 d9fa52ee200fe7644b8a30415610c444935d7d48c8d3a03501f42ca24f00a935

See more details on using hashes here.

File details

Details for the file psd2svg-0.1.1a1-py2.py3-none-any.whl.

File metadata

File hashes

Hashes for psd2svg-0.1.1a1-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 22e4c646cacc264213e9f53ee032757c099dbded7f2d45afd2955b1df5315779
MD5 bce5a8b99b64b4d5a37f8cad2de4ebaf
BLAKE2b-256 54845cc1bfd55fdd3e89232f26d26d07408fcb66664afcee399bc0b01134c1c1

See more details on using hashes here.

Supported by

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