@svgfx/cli
v0.5.0
Published
Apply post-processing effects to any SVG from the terminal. Scanlines, bloom, glitch, halftone and more.
Maintainers
Readme
@svgfx/cli
svgfx logo.svg -p crt
Post-processing effects for any SVG, straight from your shell.
Pipe it, point it at a file, a directory or a URL — get back a real SVG with scanlines, bloom, glitch, halftone or a dozen other looks baked in. Still vector, still editable, no rasterizing.
Highlights
- ✅ Pipe-first —
cat logo.svg | svgfx -p vhs > out.svgjust works. - ✅ Every input — file, directory, glob, stdin,
-, or anhttps://URL. - ✅ Stackable effects —
-eis repeatable and order preserving, exactly like the library's array. - ✅ 27 effects + 8 presets — one binary,
svgfx listto see them all. - ✅ Batch a folder —
svgfx icons/ -p riso -o dist/. - ✅ Deterministic —
--seedmakes output byte-identical run to run. - ✅ Data URIs —
--data-urifor dropping straight into CSS or HTML. - ✅ Keeps existing animation — an SVG that already animates keeps animating.
Table of contents
Installation
npm install -g @svgfx/cliOr run it without installing:
npx @svgfx/cli logo.svg -p crt -o out.svgQuick start
svgfx logo.svg -e bloom # one effect, printed to stdout
svgfx logo.svg -p crt -o out.svg # a preset, written to a file
cat logo.svg | svgfx -p vhs > out.svg # piped in, redirected out
svgfx icons/ -p riso -o dist/ # a whole directory
svgfx list # everything availableEffects stack in the order you pass them, the same way they do in the library:
svgfx logo.svg -e "bloom:radius=8" -e "scanlines:gap=3" -e "grain:amount=0.3"Input
| Form | Example |
| ---- | ------- |
| File | svgfx logo.svg -p crt |
| Several files | svgfx a.svg b.svg -e invert -o dist/ |
| Glob (shell expands it) | svgfx icons/*.svg -p riso -o dist/ |
| Directory | svgfx icons/ -p riso -o dist/ |
| Piped stdin | cat logo.svg \| svgfx -p vhs |
| Explicit stdin | svgfx - -e grain < logo.svg |
| Remote URL | svgfx https://example.com/logo.svg -p neon |
Directories are scanned one level deep for .svg files, sorted by name.
Output
| Flag | Behaviour |
| ---- | --------- |
| (none) | Writes the SVG to stdout, so it pipes and redirects |
| -o out.svg | Writes one file |
| -o dist/ | Writes into a directory, keeping each input's filename |
| -i, --in-place | Overwrites the input files |
| -u, --data-uri | Emits a data: URI instead of markup |
| -b, --base64 | Base64-encodes the data URI |
Written paths are reported on stderr, so stdout stays clean for piping. Use -q to silence it.
Effects
svgfx list prints all of these with their options.
| | |
| --- | --- |
| Light | blur bloom glow shadow |
| Colour | grayscale saturate hue-rotate invert brightness contrast sepia fade posterize threshold duotone tint |
| Texture | grain scanlines chromatic-aberration glitch pixelate halftone vignette outline wave emboss sharpen |
Options go after a colon, comma separated. Keys accept kebab-case or camelCase:
svgfx logo.svg -e "halftone:size=5,angle=15,keep-source=true"
svgfx logo.svg -e "glow:color=#ff2d55,radius=8"
svgfx logo.svg -e "grain:animate" # a bare key means true
Overlays follow your SVG's shape
scanlines, vignette and halftone lay something over the drawing rather than
filtering it. They mask that overlay to the artwork's own silhouette, so a rounded
terminal window, a logo on transparency, or anything with a non-rectangular shape keeps
its edges instead of getting a rectangle painted over it.
svgfx terminal.svg -p crt -o out.svg # rounded corners survive
svgfx terminal.svg -e scanlines:clip=viewport # opt out, fill the whole framePresets
| Preset | Look |
| ------ | ---- |
| crt | Phosphor glow, scanlines, colour fringing, vignette |
| vhs | Tape wobble, heavy fringing, rolling lines, noise |
| riso | Two-colour risograph with paper grain |
| xerox | Blown-out photocopy |
| neon | Saturated sign glow |
| film | Halation, grain and a soft vignette |
| newsprint | Halftone dots on off-white stock |
| cyberpunk | Sliced, shifted, bloomed, scanned |
Presets take options too:
svgfx logo.svg -p "riso:shadow=#2b3a67,highlight=#ff5a5f"
svgfx logo.svg -p "crt:animate=true"Options
| Flag | Default | Description |
| ---- | ------- | ----------- |
| -e, --effect | | Effect to apply. Repeatable, order preserving |
| -p, --preset | | Preset to apply. Repeatable |
| -c, --config | | JSON file holding the effect stack |
| -o, --output | stdout | Output file, or directory for several inputs |
| -i, --in-place | false | Overwrite the input files |
| -u, --data-uri | false | Emit a data: URI |
| -b, --base64 | false | Base64-encode the data URI |
| -s, --seed | svgfx | Seed for every random decision |
| --prefix | svgfx | Prefix for generated ids |
| --scope | auto | Id namespace, defaults to a hash of the input and effects |
| -a, --animate | true | Allow animation. --no-animate for a still frame |
| -f, --format | preserve | preserve, pretty or minify |
| -q, --quiet | false | Do not report written files |
Recipes
A stack you reuse, kept in a file
[
{ "effect": "duotone", "shadow": "#111d4a", "highlight": "#ffd166" },
{ "effect": "halftone", "size": 5, "angle": 15 },
"grain:amount=0.3"
]svgfx logo.svg -c poster.json -o poster.svgStraight into CSS
echo "background-image: url('$(svgfx logo.svg -p crt -u)');"Every icon in a folder, minified
svgfx icons/ -p riso -f minify -o dist/An SVG that already animates keeps animating
svgfx spinner.svg -p crt -o spinner-crt.svgReproducible output in CI
svgfx logo.svg -e glitch --seed release-42 -o out.svgLibrary
This is the terminal front end for
@svgfx/postprocessing.
Every effect, option and default is the same — reach for the library when you want
this inside a build script or an app.
npm install @svgfx/postprocessingLicense
MIT © Tal Hayut
