Skip to main content

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 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:

$ 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 (with the -F option):

$ 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):

$ ssm create -f icons.svg search.svg hamburger-icon=menu.svg -F
$ 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:

$ ssm list -f icons.svg
hamburger-icon
search

Add facebook.svg and instagram.svg to spritesheet:

$ 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:

$ 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):

$ 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:

$ 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:

$ 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:

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

License

MIT

Metadata

Release files for ssm-svg 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for ssm-svg 0.1.0
File Size Uploaded
ssm_svg-0.1.0.tar.gz 8.6 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for ssm-svg 0.1.0
File Interpreter ABI Platform
ssm_svg-0.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 15.7 kB

Release files / ssm_svg-0.1.0.tar.gz

Download URL ssm_svg-0.1.0.tar.gz
Size 8.6 kB
Tags Source
SHA-256 checksum
How to use checksums
04e0194e2b9369dc45e3b224c6a39c0f2f3cd7a8ce0c575ca72e34f95f634fe8
BLAKE2b-256 checksum
How to use checksums
a0e55f54e134de10cc8eb15eac9fc1db5b11a6aac441007fde9dcbec48559c75
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.0.0 CPython/3.12.3

Release files / ssm_svg-0.1.0-py3-none-any.whl

Download URL ssm_svg-0.1.0-py3-none-any.whl
Size 7.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
8eda7659b3e25c7d2e6f3e41362f85144539f6d7e59035c57ecc3e8631fa605d
BLAKE2b-256 checksum
How to use checksums
ff168baebc38a1d5489531aa4644a45a91bec66f64499b272fd02f3e14352641
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.0.0 CPython/3.12.3

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files

0.0.8

2 release files

0.0.7

2 release files

0.0.6

2 release files

0.0.5

2 release files

0.0.4

2 release files

0.0.2

2 release files

0.0.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page