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

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, ...

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)

The package also has rasterizer module to convert SVG to PIL Image:

from psd2svg.rasterizer import create_rasterizer

rasterizer = create_rasterizer()
image = rasterizer.rasterize(svg)
image.save('path/to/output.png')

The rasterizer requires one of Selenium + ChromeDriver, Apache Batik, or Inkscape. Make sure to install them beforehand.

Test

Invoke tox:

tox

Storage backend support

To use AWS S3 storage backend:

pip install psd2svg[s3]

or:

pip install boto3

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/

To use HDFS storage backend:

pip install psd2svg[hdfs,kerberos]

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.6.tar.gz (25.2 kB view details)

Uploaded Source

Built Distribution

psd2svg-0.1.6-py2.py3-none-any.whl (33.0 kB view details)

Uploaded Python 2 Python 3

File details

Details for the file psd2svg-0.1.6.tar.gz.

File metadata

  • Download URL: psd2svg-0.1.6.tar.gz
  • Upload date:
  • Size: 25.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.9.1 pkginfo/1.4.1 requests/2.18.4 setuptools/28.8.0 requests-toolbelt/0.8.0 tqdm/4.15.0 CPython/3.6.2

File hashes

Hashes for psd2svg-0.1.6.tar.gz
Algorithm Hash digest
SHA256 3a69e2d46d9cb2df3909ed24cbf930f5e5e94ef3304f6aac30b0c900108bf09d
MD5 342475193c7bf7dbfd7206b297e0712f
BLAKE2b-256 8e445b0035e34a289eeec482b4a57cafa5d3e43adaf0adbbd9d9d895179fa847

See more details on using hashes here.

File details

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

File metadata

  • Download URL: psd2svg-0.1.6-py2.py3-none-any.whl
  • Upload date:
  • Size: 33.0 kB
  • Tags: Python 2, Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.9.1 pkginfo/1.4.1 requests/2.18.4 setuptools/28.8.0 requests-toolbelt/0.8.0 tqdm/4.15.0 CPython/3.6.2

File hashes

Hashes for psd2svg-0.1.6-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 79005f6665e795560e0e3ee269bfd924c4b98a07891624ce91ea339a14459e56
MD5 ed8ab54c3c3af533dea42f8ec7b33c7c
BLAKE2b-256 264272ac88b567090828cb6d3727b6c8ca4e42cb3c64403a99a0c7898d343f42

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