Skip to main content

SVG spritesheet maker

Project description

ssm

SVG spritesheet maker

CI Deployment to PyPI

ssm is a command-line tool for creating and managing SVG spritesheets. It has 5 main functions:

  • create: For creating spritesheets from a list of SVG sprites (i.e. SVG icons etc.).
  • list: For listing the SVG sprites stored in a spritesheet.
  • add: For adding SVG sprites to an existing spritesheet.
  • remove: For removing SVG sprites from an existing spritesheet.
  • export: For exporting SVG sprites from an existing spritesheet; Can be used for converting a <symbol> back into a standalone <svg> or to display a format suitable for use in HTML (using <use>).

For more details, run python -m ssm -h after installation.

Installation

To install the most stable version of this package, run:

$ pip install ssm-svg

Usage example

Create spritesheet icons.svg with search.svg and menu.svg as sprites:

$ python -m ssm create -f icons.svg search.svg menu.svg
$ cat icons.svg
<svg xmlns="http://www.w3.org/2000/svg">
  <defs>
    <symbol id="search" viewBox="0 0 24 24">...</symbol>
    <symbol id="menu" viewBox="0 0 24 24">...</symbol>
  </defs>
</svg>

Create spritesheet and overwrite existing file:

$ python -m ssm create -f icons.svg search.svg menu.svg -F

Create spritesheet containing search.svg and menu.svg, with custom ID hamburger-icon for menu.svg (instead of defaulting to its file name):

$ python -m ssm create -f icons.svg search.svg hamburger-icon=menu.svg
$ cat icons.svg
<svg xmlns="http://www.w3.org/2000/svg">
  <defs>
    <symbol id="search" viewBox="0 0 24 24">...</symbol>
    <symbol id="hamburger-icon" viewBox="0 0 24 24">...</symbol>
  </defs>
</svg>

List IDs of sprites in spritesheet:

$ python -m ssm list -f icons.svg
menu
search

Add facebook.svg and instagram.svg to spritesheet:

$ python -m ssm add -f icons.svg facebook.svg instagram.svg
$ cat icons.svg
<svg xmlns="http://www.w3.org/2000/svg">
  <defs>
    <symbol id="search" viewBox="0 0 24 24">...</symbol>
    <symbol id="hamburger-icon" viewBox="0 0 24 24">...</symbol>
    <symbol id="facebook" viewBox="0 0 24 24">...</symbol>
    <symbol id="instagram" viewBox="0 0 24 24">...</symbol>
  </defs>
</svg>

Remove sprites with IDs facebook and instagram from spritesheet:

$ python -m ssm remove -f icons.svg facebook instagram
$ cat icons.svg
<svg xmlns="http://www.w3.org/2000/svg">
  <defs>
    <symbol id="search" viewBox="0 0 24 24">...</symbol>
    <symbol id="hamburger-icon" viewBox="0 0 24 24">...</symbol>
  </defs>
</svg>

NOTE: Inserting the same ID more than once would cause an error.

Add facebook.svg to spritesheet with custom ID fb-icon (instead of defaulting to its file name):

$ python -m ssm add -f icons.svg fb-icon=facebook.svg
$ cat icons.svg
<svg xmlns="http://www.w3.org/2000/svg">
  <defs>
    <symbol id="search" viewBox="0 0 24 24">...</symbol>
    <symbol id="hamburger-icon" viewBox="0 0 24 24">...</symbol>
    <symbol id="fb-icon" viewBox="0 0 24 24">...</symbol>
  </defs>
</svg>

Export sprite with ID menu from spritesheet:

$ python -m ssm export -f icons.svg menu
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24">
    <!-- "menu" SVG elements -->
</svg>

Export sprite with ID menu from spritesheet for use in HTML:

$ python -m ssm export -f icons.svg menu --use
<svg><use href="icons.svg#menu"></use></svg>

Export sprites with IDs search and menu from spritesheet as exported_files/search.svg and exported_files/menu.svg respectively:

$ python -m ssm export -f icons.svg --dir exported_files search menu
$ cat exported_files/menu.svg
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24">
    <!-- "menu" SVG elements -->
</svg>
$ cat exported_files/search.svg
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24">
    <!-- "search" SVG elements -->
</svg>

License

MIT

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

ssm_svg-0.0.6.tar.gz (8.6 kB view details)

Uploaded Source

Built Distribution

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

ssm_svg-0.0.6-py3-none-any.whl (7.1 kB view details)

Uploaded Python 3

File details

Details for the file ssm_svg-0.0.6.tar.gz.

File metadata

  • Download URL: ssm_svg-0.0.6.tar.gz
  • Upload date:
  • Size: 8.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.0.0 CPython/3.12.3

File hashes

Hashes for ssm_svg-0.0.6.tar.gz
Algorithm Hash digest
SHA256 b2fb1372b45a83e598705345b2553892f1f2bb7ee1cbe26cab4cfd2a0f4a20d3
MD5 0c127159c2817092bab4e2afe04acb6c
BLAKE2b-256 7c3856abdefb0fb67b927ffe821264e820196afc037798e5bb00297fc0890d42

See more details on using hashes here.

File details

Details for the file ssm_svg-0.0.6-py3-none-any.whl.

File metadata

  • Download URL: ssm_svg-0.0.6-py3-none-any.whl
  • Upload date:
  • Size: 7.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.0.0 CPython/3.12.3

File hashes

Hashes for ssm_svg-0.0.6-py3-none-any.whl
Algorithm Hash digest
SHA256 66b4c5e6644aa9aa34a6c32f34cffd67297bf1f1edaf1bbb280aae1fc2108da3
MD5 c3f926ce1418d2e1df4e5b63af281949
BLAKE2b-256 979c1ebc26c470efa87441f50e328f4db279a2a2474bc868854ca7f3a9a59f65

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