A simple css sprite generator.
Free software: BSD 2-Clause License
Installation
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
Usage
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 1
index0 - counter starting from 0
filename - path to source image
offset - dict with fields: x and y (integers)
position - dict with fields: x and y (integers)
width - integer (same as cell.width for now)
height - integer (same as cell.height for now)
grid - dict with fields
width - integer
height - integer
vertical - bool (True if you have used --vertical)
cell - dict with fields:
count - number of input images
width - integer
height - integer
output - pathlib.Path of output file
Documentation
Development
To run all the tests run:
tox
Note, to combine the coverage data from all the tox environments run:
Windows |
set PYTEST_ADDOPTS=--cov-append tox |
|---|---|
Other |
PYTEST_ADDOPTS=--cov-append tox |
Changelog
0.2.0 (2022-05-06)
Allow images to overlap by using alpha composition. Useful when cell is smaller than images, and images are transparent.
Restructure template context. BACKWARDS INCOMPATIBLE
0.1.1 (2022-04-18)
Remove the universal flag (don’t produce py2.py3 wheels since py2 isn’t supported anyway).
0.1.0 (2022-04-18)
First release on PyPI.
Metadata
Release files for css-sprite 0.2.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| css-sprite-0.2.0.tar.gz | 19.2 kB | Without provenance | Details for css-sprite-0.2.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| css_sprite-0.2.0-py3-none-any.whl | Python 3 | none | any | Details for css_sprite-0.2.0-py3-none-any.whl |
Total release size: 26.0 kB
Release files / css-sprite-0.2.0.tar.gz
| Download URL | css-sprite-0.2.0.tar.gz |
|---|---|
| Size | 19.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
b302899c232a28e322768a0f916cbaad4ddba8e7c89eb2cc279b0e55ad761ca5
|
|
BLAKE2b-256 checksum How to use checksums |
39535301c6b251b257583d9d07eb2cb769520c32891c6503f8f7e973359c4b8c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.7.0 importlib_metadata/4.8.2 pkginfo/1.8.2 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.10.4
|
Release files / css_sprite-0.2.0-py3-none-any.whl
| Download URL | css_sprite-0.2.0-py3-none-any.whl |
|---|---|
| Size | 6.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
e7711899acd806dede0e18a64ce982f93577d1b719960759add102b1b0cb0260
|
|
BLAKE2b-256 checksum How to use checksums |
34050038a7245fd2d1394f76cdd5782d2abee8129464b89be0a2162e2097c48e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.7.0 importlib_metadata/4.8.2 pkginfo/1.8.2 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.10.4
|
Security for css-sprite 0.2.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.