Skip to main content

Converts subset of SVG 1.1 to SSA v4+

Project description

Warning

SVG generated by Inkscape changed so much since svg2ssa was first written, that default output of modern Inkscape versions is more likely to be broken than before. E.g., svg2ssa doesn't understand elements like circle which in previous versions were stored as path (in this particular example it will suffice to select such objects and execute this command: Menu > Path > Object to Path). It still may be useful as an alternative to ASSDraw, but it's much less convenient than before. I guess someone could write accompanying Inkscape script to use Inkscape's own logic to simplify this, or even turn svg2ssa into Inkscape extension, but it won't be me... Esp. not now when Russians plan to continue their invasion in Ukraine.

About

svg2ssa is a converter written in Python 3 that is intended to convert vector graphics from SVG produced by Inkscape (although there's a possibility that it can chew SVG from other editors as well) to SSA used by VSFilter (mainly because of handling progressive collisions with \org(0,0) w/o the need of change of sub's z-layer value).

The main audience of this software is "advanced" anime typesetters. svg2ssa will help them to create their graphics inside more neat, usable & specifically designed editor like Inkscape. It's hard to enumerate all possible uses and benefits: for some they are minor and not worth it, but for others they may be almost infinite. E.g., Inkscape's feature to trace bitmaps (despite some limits), render 3D objects from Wavefront *.OBJ files produced by Blender, convert text to shapes. BTW, conversion of text to shapes means that there's no need to embed fonts for a few titles containing a few letters, maybe even drop font embedding altogether.

How to use

  1. acquire version of svg2ssa: I. install from PyPI: a. pip install svg2ssa - for use with safe XML parser defusedxml. b. pip install svg2ssa[fast-parsing] - for use with fast XML parser lxml. Note that for it to be used, you'll have to add explicit flag -p lxml.etree. II. download one of the standalone executables for Windows at https://github.com/8day/svg2ssa/releases.
  2. convert SVG to SSA: python -m svg2ssa -i "c:\path to dir\with\file.svg" -o "c:\path to another dir\with\file.ass".
  3. for more info: python -m svg2ssa --help.

Misc info

The most notable features of Inkscape & svg2ssa combo

  • bitmap tracing:
    • load & select raster image;
    • go to Menu > Path > Trace Bitmap...;
    • apply filter with desired settings (try Mode > Multiple scans > Colors).
  • rendering of 3D objects (plain models w/o smoothing since it'll require rasterization):
    • build your own model with Blender;
    • while in Blender, export it to Wevefront *.OBJ by going to Menu > File > Export > Wevefront (.obj);
    • in Inkscape go to Menu > Extensions > Render > 3D Polyhedron > Model file > Object > Load from file;
    • in Filename edit-box paste path to *.OBJ file;
    • in Style > Z-sort faces by you may want to select Centroid.
  • conversion of text to shape:
    • create some text inside Inkscape;
    • select it;
    • go to Menu > Path > Object to Path.

The most notable features of svg2ssa

  • subpixel precision by changing the size of coordinate system (\pN along with hardcoded scaling of drawings; S2S key: -m {int});
  • ability to choose whether to hardcode trafos or convert them to SSA equivalents (S2S key: -t {scale, translate, rotate});
  • other features and how-to can be found by typing python -m svg2ssa --help in your terminal.

What you may want to know

  • as Aegisub, both svg2ssa and Inkscape are cross-platform;
  • stroke rendering in SVG & SSA are a bit different (see Inkscape > Menu > Object > Fill and Stroke... > Stroke style > Join/Cap):
    • in SVG you can set types of segment's joining & capping, but in SSA/VSFilter it's always Round join & Round cap;
    • see difference in how SVG & SSA lay down stroke in s2s-stroke-preservation.svg or rendered PNG: SVG lays down its stroke in the middle of shape's contour, but SSA lays it down outside.
  • VSFilter always uses SVG's analogue of fill-rule: nonzero, so select it inside Inkscape so that your SSA drawings looked the same as SVG (Inkscape > Menu > Object > Fill and Stroke... > Fill > *two V-like black shapes at the top right corner of the tab*, select the one that is completely black);
  • it may have some issues with relatively highlevel SVG concepts (especially raster images, text, clipping, masking, compositing etc.), but it should suffice as a replacement for ASSDraw/Aegisub: to draw graphics easier & faster;
  • it supports only subset of drawing commands: M, L, H, V, C, S, Q, T and not Z or A (A may be converted to C/S by selecting object in question and executing Menu > Path > Simplify; doesn't always work as expected);
  • it supports only path elements. Some other elements, like circle, can be converted to path by selecting them and executing Menu > Path > Object to Path;
  • viewBox attribute will mess up rendering (likely to be smaller than expected) -- make sure it's not used.
  • there might be erroneous conversions, especially with color and opacity (they are rear, but still they are present; in this case simplify your graphics/SVG structure by collapsing groups etc.);
  • there's no support for *.gzip files;
  • there are similar to this scripts, but which are not "standalone": tophf's AegiDrawing for CorelDRAW and torque's AI2ASS for Illustrator.

What you must know

  • this app has no Graphical User Interface, only Command Line Interface;
  • in order for it to work you need to have some version of Python 3 installed on your computer (worked with 3.2.5), or if you use Windows you can download standalone app (you can download either s2s-xml.etree.7z or s2s-lxml.7z, but latter should be faster);
  • XML can be dangerous, so you may want to use package defusedxml instead of either built-in xml or fast lxml. When installing svg2ssa through pip, you may want to use this command pip install svg2ssa[safe-parsing] to install defusedxml as well.
  • since SVG is very complex, this software was made to work with SVGs generated by Inkscape. Illustrator won't work, also some other browser-based editors might not work;
  • the initial purpose was to bridge the gap between fansubbers and a world of more advanced vector editing, but not to be a converter that supports SVG by a 100% (there's probably no such software at all (!));
  • probably will work as intended only with VSFilter.

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

svg2ssa-2022.12.23.0.tar.gz (25.4 kB view details)

Uploaded Source

Built Distribution

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

svg2ssa-2022.12.23.0-py3-none-any.whl (26.1 kB view details)

Uploaded Python 3

File details

Details for the file svg2ssa-2022.12.23.0.tar.gz.

File metadata

  • Download URL: svg2ssa-2022.12.23.0.tar.gz
  • Upload date:
  • Size: 25.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.3.1 CPython/3.10.9 Windows/10

File hashes

Hashes for svg2ssa-2022.12.23.0.tar.gz
Algorithm Hash digest
SHA256 e85238e7f4eb7ed2a6765f29a225f96b9af816b8d6584e6618842af00b8a5202
MD5 05eedf449465e55f4bf3c701292f3dad
BLAKE2b-256 45ff57a9d30810462d51f7dd628e6a58f4ecf6b8dba3443e1e9d8936b2562631

See more details on using hashes here.

File details

Details for the file svg2ssa-2022.12.23.0-py3-none-any.whl.

File metadata

  • Download URL: svg2ssa-2022.12.23.0-py3-none-any.whl
  • Upload date:
  • Size: 26.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.3.1 CPython/3.10.9 Windows/10

File hashes

Hashes for svg2ssa-2022.12.23.0-py3-none-any.whl
Algorithm Hash digest
SHA256 4b57a2487dc71860a58df02672c0f0ab944fcf56cfd90e90686cbf83ab3be095
MD5 073b6299e36a4e77b2bb52b58a45a8d7
BLAKE2b-256 c512f551ee41693b6efaf2bece12bed6fb33fe1812674ae8fabee3ff1c063765

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