Skip to main content
Warning: You are using the test version of PyPI. This is a pre-production deployment of Warehouse. Changes made here affect the production instance of TestPyPI (
Help us improve Python packaging - Donate today!

Python library to generate sprites from source SVG files

Project Description


|copyright| 2014 Thomas Khyn

Python package to generate sprites from SVG files directories

This package is inspired from Iconizr_ and grunt-iconizr_ by Joschi Kuphal.

From Joschi's words, Iconizr ...::

... takes a folder of SVG images and creates a CSS icon kit out of them.
Depending on the client's capabilities, icons are served as SVG / PNG
sprite or embedded data URIs. iconizr creates suitable CSS / Sass / LESS
etc. resources and a JavaScript loader for easy integration into your
HTML documents.


As straighforward as it can be, using ``pip``::

pip install pyconizr


From the command line:: [options]

From python::

from pyconizr import iconize

Default behavior

By default, pyconizr will:
- optimize every SVG file in the current working directory using scour_
(without overwriting them)
- concatenate them to create an optimized SVG sprite in
- create a PNG sprite from the SVG sprite as
- create a CSS/SCSS/LESS file at current_working_dir/sourcedir_name

This can be configured using the following options.


All options should be prefixed by ``--`` in the command line (if not using the
shortcut), or should be provided as keyword arguments to the ``iconize``

in, -i
The input directory or files (as a wildcard) that should be used to generate
the sprite.
Only valid SVG files will be taken into account, so there is no need to add
a \*.svg wildcard ("dir/\*" will only include the \*.svg files in dir).
Defaults to the current working directory.

out, -o
The output path for the generated output file (CSS, SASS...). The directory
will be created if it does not already exist.
Defaults to the 'out' directory in the current working directory.

out-sprite, -s
The output path for the SVG and PNG sprites. The directory will be created
if it does not already exist.
Defaults to the 'sprites' directory in the output directory.

The output path for the optimized SVG and rasterized PNG individual icons.
If left blank, no icons will be generated. If defined, a supplementary
output file will be generated with a '-icons' suffix.
Defaults to blank (no icons generated).

render, -r
How the output should be rendered. Can be:
- css: for CSS output [default]\n'
- scss: for SASS output\n'
- no: no output (to simply generate a sprite)\n'
- a path to a custom Jinja2_ template file for a 100% custom output

The absolute URL to the static directory. Used for links towards sprites and
icons files from within the generated outputs.
Defaults to ``/static``

The absolute or relative (to static-url) URL to the sprites directory. Used
for links towards sprite files.
Defaults to ``sprites``

The absolute or relative (to static-url) URL to the icons directory. Used
for links towards individual icons. Not used if out-icons is not defined.
Defaults to ``icons``

A common CSS class for all the icons in the sprite.
Default to ``None``.

Should png fallbacks be generated? If True, PNG sprites will be generated
and used by any icon bearing a 'nosvg' class.
Defaults to ``True``

Should SVG and PNG images be linked as dataURIs? Remember that a page loads
faster (thanks to caching vs dataURI decoding) if the CSS does not use
Defaults to ``False``

Comma-separated list of selectors that can be embedded in icons filenames,
using the ``_`` separator. For example, there a file name_hover.svg will be
taken as the hovered version of the icon name.
Defaults to ``hover,target,active``

All the options from scour_, using the 'scour-' prefix. 'strip-xml-prolog'
becomes 'scour-strip-xml-prolog'
Defaults to best possible optimisation parameters for sprite generation.

.. |copyright| unicode:: 0xA9

.. _Iconizr:
.. _grunt-iconizr:
.. _scour:
.. _Jinja2:

Release History

This version
History Node


Supported By

WebFaction WebFaction Technical Writing Elastic Elastic Search Pingdom Pingdom Monitoring Dyn Dyn DNS Sentry Sentry Error Logging CloudAMQP CloudAMQP RabbitMQ Heroku Heroku PaaS Kabu Creative Kabu Creative UX & Design Fastly Fastly CDN DigiCert DigiCert EV Certificate Rackspace Rackspace Cloud Servers DreamHost DreamHost Log Hosting