Convert PSD file to SVG file
Project description
PSD to SVG converter based on psd-tools and svgwrite.
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 --resource-path flag is specified, all png resources are exported to the path specified by --resource-path:
psd2svg input.psd output.svg --resource-path . # => output.svg, xxx1.png, ... psd2svg input.psd output/ --resource-path . # => output/input.svg, output/xxx1.png, ... psd2svg input.psd output/ --resource-path=resources/ # => output/input.svg, output/resources/xxx1.png, ... psd2svg input.psd svg/ --resource-path=../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 directly rendered.
layer_svg = psd2svg(psd[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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file psd2svg-0.2.3.tar.gz
.
File metadata
- Download URL: psd2svg-0.2.3.tar.gz
- Upload date:
- Size: 25.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/40.6.2 requests-toolbelt/0.9.1 tqdm/4.45.0 CPython/3.6.10
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1aeccd0855c20ccf797fadbed782a4ece8937d7f7510974fcf8820ce23bf38f4 |
|
MD5 | dc0340e60edbc75198c8a126c7fa54fc |
|
BLAKE2b-256 | ad9263a864b19fcd608080890983c17e5aadb57dcbc295898893650d5aa4e702 |
File details
Details for the file psd2svg-0.2.3-py2.py3-none-any.whl
.
File metadata
- Download URL: psd2svg-0.2.3-py2.py3-none-any.whl
- Upload date:
- Size: 31.6 kB
- Tags: Python 2, Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/40.6.2 requests-toolbelt/0.9.1 tqdm/4.45.0 CPython/3.6.10
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | f9b34f1909384580c440a60771749d6cbc394c2ee8d61d7007aaaf324f5e920f |
|
MD5 | 9d0deba8ed313347d2a680947489d7b5 |
|
BLAKE2b-256 | 3a570f2b771f252afb78d09cb03ebdfe05224f0eaab32bf8b0523ff213dcfb36 |