svgx - Man Page

extract gradients from SVG files.


svgx [-a] [-b rgb] [-f rgb] [-g geometry] [-h] [-l] [-n rgb] [-o file] [-p] [-s name] [-t type] [-T rgb] [-v] [-V] file


The svgx program extracts and converts gradients in an SVG file. Unlike most of the other file formats handled by the cptutils package, SVG files may contain multiple gradients, so this program operates a little differently to the other programs in the package.

There are 4 modes of operation: The default is to extract the first gradient found in the file, or one can specify -l to list the names of all gradients in the file; -s to extract the gradient with the specified name or -a to extract all of the gradients.

The output format is specified by the -t option as listed below (in fact there are several aliases for each format: jgd for psp, ggr for gimp and so on). The svgcpt, svgcss3, svggimp, svggpt, svgmap, svgpg, svgpsp, svgpov, svgpng, svgqgs, svgsao, svgsvg programs are wrappers around svgx which use the -t switch to specify output type.

Atypically, the input SVG file is a mandatory argument. The program will write to stdout if the -o option is not specified except when -a has been specified: then files will be produced (with names taken from those of the gradients).

Note that some of the SVG conversions require that the en_US.utf8 locale be enabled. How this is done will depend on your operating system. One would run

apt-get install locales
dpkg-reconfigure locales

on Debian-based systems, for example.


In the following, all rgb specifications should be of the form red/green/blue where the colour components are integers in the range 0 to 255.

-a,  --all

Extract all gradients, which will have filenames derived from the gradient names. If this option is used then the argument of the -o option will be interpreted as the output directory.

-b,  --background rgb

Set the background colour of cpt output.

Note that this only modifies the "background" field in the output cpt file, it does not affect the transparency (see the -T option in that regard).

--backtrace-file path

Specify a file to which to write a formatted backtrace. The file will only be created if there is a backtrace created, typically when an error occurs.

--backtrace-format format

Specify the format of the backtrace written to the files specified by --backtrace-file, one of plain, xml or json.

-f,  --foreground rgb

Set the foreground colour of cpt output.

-g,  --geometry widthxheight

Specify the size of the PNG image or SVG preview in pixels.

-h,  --help

Brief help.

-l,  --list

List the names of all gradients in the file.

-n,  --nan rgb

Set the NaN (no data) colour of cpt output.

-o,  --output path

Write the output to path, rather than stdout.

If the -a option is specified then the path argument must be a directory (which exists) and the output files will be written into this directory.

-p,  --preview

Include a preview in the SVG output. See also the --geometry option.


Do not create files which break limits of the format specification. In particular, do not create POV-Ray headers with more than 255 stops, do not create Tecplot maps with more than 50 points.

-s,  --select name

Extract the gradient with the specified name, see the -l output for a list of possible values.

-t,  --type format

Set the output format, which should be one of cpt, css3, ggr, gpt, map, psp, pov, png, qgs, sao or svg.

-T,  --transparency rgb

When converting to a format which does not support transparency, replace the transparency with the specified rgb colour.

-v,  --verbose

Verbose operation.

-V,  --version

Version information.


Inspect an SVG file for gradients:

svgx -v -l old.svg

Extract the gradient "Sunny Road" from the same SVG file, converting the result to cpt: (note that the gradient name needs to be quoted)

svgx -v -t cpt -s "Sunny Road" -o sunny_road.cpt old.svg

Extract all of the svg gradients from the file kittens.svg and give each of them a preview:

svgx -v -t svg -a -p kittens.svg


An ill-formed SVG gradient may be translated to rubbish while not reporting an error.

When converting between types in several calls to different programs, one should note that the SVG format preserves the alpha channel, but will coerce the range to [1, 100]. So converting from CPT to PG via cptsvg and svgpg one loses the CPT range information, while using cptpg will perserve it. Conversely, converting SGV to PG via svgcpt and cptpg will lose the alpha channel, while svgpg will not. This is the reason for the apparent duplication of functionality in the package.


J.J. Green

See Also

cptsvg(1), gimpsvg(1), pspsvg(1).

Referenced By

gimplut(1), pssvg(1).

6 September 2023 cptutils 1.77 User commands