Python script to render SVG icons to PNG icons in various sizes
Project description
render-svg-icons
is a python script for rendering SVG icons to PNG icons in various sizes. While it runs on both Linux and macOS, it currently uses a specific SVG template and a folder structure based on the XDG Icon Theme Specification.
Provenance
I've come across the progenitor of this script in multiple places. It seems to have originated with GNOME, but it's not entirely clear.
Development Status
render-svg-icons
should basically work for its original purpose of rendering XDG icon themes. I plan to continue adapting the code to make it easier to use and to allow for more flexible use cases in the future.
While I plan to leave the command-line interface more or less intact, it and the implementation thereof shouldn't be considered stable at the moment. If you plan to call render-svg-icons
as a dependency, you should specify an exact version you know to work for your purposes.
Installation
For day-to-day use, you should install render-svg-icons
from PyPI:
$ pip install render-svg-icons
For development purposes, you can build and install render-svg-icons
from the cloned repository using Poetry.
To install Poetry, run:
$ curl -sSL https://raw.githubusercontent.com/python-poetry/poetry/master/get-poetry.py | python -
Then, from the render-svg-icons
cloned repository, run:
$ poetry build
$ pip install --force-reinstall dist/*.whl
This will install the repository code in the same manner as the PyPI version. (The --force-reinstall
causes it to overwrite any other installed version.)
To uninstall either version of render-svg-icons
, run:
$ pip uninstall render-svg-icons
Dependencies
render-svg-icons
requires both Inkscape and OptiPNG.
Linux
To install Inkscape and OptiPNG on, e.g., Debian, Ubuntu, etc.:
$ sudo apt install inkscape optipng
(For Fedora, Arch, etc., I'm sure you know what you're doing.)
macOS
To install Inkscape and OptiPNG on macOS, first install Homebrew if you haven't already:
% /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
Then use Homebrew to install Inkscape and OptiPNG:
% brew install inkscape optipng
You can probably use other installation methods, but you may need to specify the executable path if it's different from the one used by Homebrew.
Other Platforms
render-svg-icons
isn't currently compatible with platforms other than Linux and macOS. If you'd like to use this on another platform, please open an issue or a pull request.
Usage
After installation:
$ render_svg_icons --help
┌──────────────────────────────────────────────────┐
│ Render icons from SVG to PNG │
└──────────────────────────────────────────────────┘
┌──────────────────────────────────────────────────┐
│ Usage │
├──────────────────────────────────────────────────┤
│ $ render_svg_icons │
│ [--help] │
│ [--base_dpi BASE_DPI] │
│ [--categories [CATEGORIES]] │
│ [--filter FILTER] │
│ [--inkscape_path INKSCAPE_PATH] │
│ [--individual_icons [INDIVIDUAL_ICONS]] │
│ [--optipng_path OPTIPNG_PATH] │
│ [--output_path OUTPUT_PATH] │
│ [--scaling_factors [SCALING_FACTORS]] │
│ [--verbose] │
│ │
└──────────────────────────────────────────────────┘
┌──────────────────────────────────────────────────┐
│ Optional Arguments │
├──────────────────────────────────────────────────┤
│ --help │
│ │
│ Show this help message and exit. │
│ │
│ --base_dpi BASE_DPI │
│ │
│ dpi to use for rendering (by default 96) │
│ │
│ --categories [CATEGORIES] │
│ │
│ categories of icons to render (by default all) │
│ │
│ --filter FILTER │
│ │
│ Inkscape filter to apply while rendering │
│ (by default none) │
│ │
│ --inkscape_path INKSCAPE_PATH │
│ │
│ path of Inkscape executable │
│ (if the script can't find it) │
│ │
│ --individual_icons [INDIVIDUAL_ICONS] │
│ │
│ individual icon names (without extensions) │
│ to render (by default all) │
│ │
│ --optipng_path OPTIPNG_PATH │
│ │
│ path of OptiPNG executable │
│ (if the script can't find it) │
│ │
│ --output_path OUTPUT_PATH │
│ │
│ output directory (by default '.') │
│ │
│ --scaling_factors [SCALING_FACTORS] │
│ │
│ scaling factors to render at │
│ (by default [1, 2], e.g. 100% & 200%) │
│ │
│ --verbose │
│ │
│ print verbose output to the terminal │
│ │
└──────────────────────────────────────────────────┘
License
render-svg-icons
is published under the GPLv3 or later (i.e. you can use it for proprietary purposes via the command line, but you can only link to it from other GPL code).
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file render-svg-icons-0.1.0.tar.gz
.
File metadata
- Download URL: render-svg-icons-0.1.0.tar.gz
- Upload date:
- Size: 22.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.2 importlib_metadata/4.6.4 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.8.3
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 89d3ae19abf393fc92ec6adf5fd928616edc8670eea06ed62fac3d67fda0c354 |
|
MD5 | 6e24f91f0cd8cd218df1f729064cbfe9 |
|
BLAKE2b-256 | 95746d244ea5a3c218ac3e5b97eaf8e4e2287389066e37fed0b1309279849c85 |
File details
Details for the file render_svg_icons-0.1.0-py3-none-any.whl
.
File metadata
- Download URL: render_svg_icons-0.1.0-py3-none-any.whl
- Upload date:
- Size: 24.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.2 importlib_metadata/4.6.4 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.8.3
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 26fcd3762ab18280b3fe7c8f6bdb9468291036a12aafb1c53926546b7fca4526 |
|
MD5 | 921e776069ce7f6d07cc79080107e0c2 |
|
BLAKE2b-256 | a1fb8787d14b0396a07dd49b24532cc07fbfd1575c336c00fbf7e83b10cdd96a |