add --export-extension option
Previously, exporting using the command line was only possible to a limited and hardcoded set of file formats. This merge request allows to use any export extension and generalizes the existing code (since all export options except PNG are extensions anyway).
If multiple extensions for the specified output file type are available, it is possible to specify the extension to be used with the --export-extension
command line option, which accepts an ID of an extension.
Some examples:
-
inkscape --export-filename="test.dxf" input.svg
(outputs the file with the first extension it found) -
inkscape --export-filename="test.dxf" input.svg --export-extension=whatever
InkFileExportCmd::do_export: The supplied extension ID (whatever) does not match any of the extensions available for this file type. Supported IDs for this file type: [org.inkscape.output.dxf_twelve, org.ekips.output.dxf_outlines]
-
inkscape --export-filename="test.svg" input.svg --export-extension=org.inkscape.output.svg.plain
is eqivalent toinkscape --export-filename="test.svg" input.svg --export-plain-svg
-
inkscape --export-filename="test.abc" input.svg
InkFileExportCmd::do_export: Unknown export type: abc. Allowed values: [.dxf, .emf, .eps, .fxg, .gpl, .hpgl, .html, .odg, .pdf, .png, .pov, .ps, .sif, .svg, .svgz, .tar, .tex, .wmf, .xaml, .zip]
- Only special case is PNG:
inkscape --export-filename="test.png" input.svg --export-extension=whatever
InkFileExportCmd::do_export: The parameter --export-extension is invalid for PNG export
- We can also guess the file extension from specifying an extension:
inkscape --export-filename="test" input.svg --export-extension=org.inkscape.output.svg.plain
- You'll get an error message if the extension you supplied doesn't exist:
inkscape --export-filename="test" input.svg --export-extension=whatever
InkFileExportCmd::do_export: The supplied --export-extension was not found. Specify a file extension to get a list of available extensions for this file type.
- However, multiple filetypes are not allowed:
inkscape --export-filename="test" --export-type="svg,png" input.svg --export-extension=org.inkscape.output.svg.plain
InkFileExportCmd::do_export: You may only specify one export type if --export-extension is supplied
Closes inbox#2121 (closed).
TODO:
-
run clang-tidy -
check existing unit tests -
add more unit tests for new export option -
discuss how to pass export extension parameters via command line -
discuss whether we should guess the --export-type
from the provided extension -
should we allow to pass multiple extensions (in case multiple --export-type
s were entered?) -
document this on the man page -
check if "shortcut" has a measurable speedup -
lowercase file extensions
Edited by Jonathan Neuhauser