docs | |
tests | |
package |
A simple css sprite generator.
- Free software: BSD 2-Clause License
pip install css-sprite
You can also install the in-development version with:
pip install https://github.com/ionelmc/python-css-sprite/archive/main.zip
To generate a css sprite from images:
css-sprite [-h] [--grid GRID] --output OUTPUT
[--mode MODE] [--vertical] [--background BACKGROUND]
[--template TEMPLATE | --template-path TEMPLATE_PATH]
[--verbose] [--version] image [image ...]
Output is mainly a new image but you can also generate the accompanying css.
- Positional arguments:
image Path to image to include in sprite.
- Options:
-h, --help show this help message and exit --grid GRID, -g GRID Grid cell size to use. One of: auto, X:Y. --output OUTPUT, -o OUTPUT Output file. --mode MODE, -m MODE Force a certain image mode in the output, see: https://pillow.readthedocs.io/en/latest/handbook/concepts.html#modes. --vertical, -v Stack the images vertically (they are stacked horizontally by default). --background BACKGROUND, -b BACKGROUND Background color. --template TEMPLATE, -t TEMPLATE Jinja template for CSS output on stdout. --template-path TEMPLATE_PATH, -p TEMPLATE_PATH Jinja template path for CSS output on stdout. --verbose Make output verbose. --version show program's version number and exit
Template variables:
images
- list of dicts with fields:index
- counter starting from 1index0
- counter starting from 0filename
- path to source imageoffset
- dict with fields:x
andy
(integers)position
- dict with fields:x
andy
(integers)width
- integer (same ascell.width
for now)height
- integer (same ascell.height
for now)
grid
- dict with fieldswidth
- integerheight
- integervertical
- bool (True
if you have used--vertical
)
cell
- dict with fields:count
- number of input imageswidth
- integerheight
- integer
output
- pathlib.Path of output file
https://python-css-sprite.readthedocs.io/
To run all the tests run:
tox
Note, to combine the coverage data from all the tox environments run:
Windows |
|
Other |
|