Name

pssvg — convert Photoshop® gradients to SVG.

Synopsis

pssvg [-b rgb] [-f rgb] [-F format] [-h ] [-o path] [-v ] [-V ] path

DESCRIPTION

The pssvg program converts Photoshop grd5 gradients to the SVG format. Unlike most of the other file formats handled by the cptutils package, grd5 files may contain multiple gradients and all of the input gradients will be converted to gradients in the output file. One can then use svgx (1) to extract single gradients and convert them to other formats.

Photoshop gradient files will often contain a number of gradients with the same name. These names are used as the basis for the SVG id attributes, but since these must be unique, the program will append -01, -02, ... to duplicate names in order to form the ids, as well a replacing non-alphanumeric by hyphens and prepending the string id-. Alternatively once can employ the --id-format option to generate a uniform sequence of titles.

The program will read from stdin if a file is not specified as the final argument, and write to stdout if the --output option is not specified.

OPTIONS

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.

-b, --background rgb

Set the background colour of the output.

--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.

--comments-read path

Read the comments from the specified path and add them to the output gradient.

The format is custom XML which should be fairly easy to generate, see the output of --comments-write for examples.

--comments-generate

Create a comment with summary data (the date of creation, name and version of the cptutils package) in the output file.

-f, --foreground rgb

Set the foreground colour of the output.

-F, --id-format format

This option generates the SVG gradient id attributes according to the specified format.

The format argument should be a printf (3) format string containing a single integer directive (and that directive will be replaced by the gradient number). Thus "id-%03i" will produce ids "id-001", "id-002", ...

Note that passing a format string which does not contain a single integer directive will result in undefined behaviour (in the C sense) so one should only use trusted sources for this string.

-h, --help

Brief help.

-o, --output path

Write the output to path, rather than stdout.

-v, --verbose

Verbose operation.

-V, --version

Version information.

EXAMPLE

Convert a Photoshop gradient, foo.grd, to a set of GIMP gradients, foo-001.ggr, foo-002.ggr, ...

pssvg -v -F "foo-%03i" -o tmp.svg foo.grd
svggimp -v -a tmp.svg

CAVEATS

The program handles RGB, HSB, LAB, CMYK and greyscale colour stops, converting them all to RGB and then merging the results with the opacity channel to create SVG RGBA stops. Conversion of non-RGB stops is naive and takes no account of colour profiles, so the results are generally sub-optimal. Integration of a CMS (colour management system) into the program to perform these conversions is under investigation.

The program does not handle "Book Colours" (PANTONE, COLOR FINDER, etc) for legal reasons.

The SVG output format does not support back/foreground colours; consequently, if the input specifies any stops with back/foreground colours then these will be converted to the colour specified by the --background and --foreground options, respectively.

The smoothness parameter used by Photoshop (which seems to parameterise some kind of spline) is not yet handled; the output contains only linear splines (corresponding to a smoothness of 0%). The result is that the SVG output will sometimes look more "angular" than the Photoshop input. Fixing this will require research into the precise nature of the spline parameterisation used in the input.

Noise gradients would seem to be difficult to convert to SVG without using a huge number of stops in the output, so these will probably not be supported by this program.

NOTES

Adobe Photoshop® is a trademark of Adobe Systems Inc. PANTONE® is a trademark of Pantone LLC. COLOR FINDER® is a trademark of Toyo Ink Mfg. Co., Ltd.

This program was written using the reverse-engineered specification of the grd5 format by Valek Filippov, Alexandre Prokoudine and Michel Mariani.

AUTHOR

J.J. Green

SEE ALSO

svgx (1) .