CLI: Add correct support for --export-id + --export-id-only + --export-area-drawing combination

Steps to reproduce:

  • Download this input file: theta.svg
  • Run these commands:
inkscape --export-id=yellow --export-id-only --export-area-drawing --export-filename=export.png theta.svg
inkscape --export-id=yellow --export-id-only --export-area-drawing --export-filename=export.svg theta.svg
inkscape --export-id=yellow --export-id-only --export-area-drawing --export-filename=export.pdf theta.svg
inkscape --export-id=yellow --export-id-only --export-area-drawing --export-filename=export.ps  theta.svg
inkscape --export-id=yellow --export-id-only --export-area-drawing --export-filename=export.eps theta.svg
inkscape --export-id=yellow --export-id-only --export-area-drawing --export-filename=export.emf theta.svg
inkscape --export-id=yellow --export-id-only --export-area-drawing --export-filename=export.wmf theta.svg

What happened?

  • Output: output.7z
  • SVG export is fine, that is what I expect: export.svg
  • All other formats are doing something other:
    • EMF/WFM depends from #1204
    • PNG, PDF, EPS, PS exports what is expected for --export-id=yellow+--export-id-only (without --export-area-drawing)

What should have happened?

  • The expected output is same as the SVG export: Delete all object from the canvas except the given object and preserve the original canvas size.
  • Please consider hierarchy of the existing options:

inkscape_CLI_export_options.svg

  • When more options is given, the executing goes from top to bottom:
    • First step: decide what to export: all objects or only one object (--export-id+--export-id-only)
    • Second step: select the area: the full page, or the drawing's bounding box, or a special area, or the area of the given object specified with --export-id (--export-id-only does not matter here).
    • etc.
  • It this case it's important to not mix the 1st and 2nd step: If --export-id+--export-id-only is given, it doesn’t mean that we know the expected export area, we should check for other options.

0.92.4

inkscape --export-id=yellow --export-id-only --export-area-drawing --export-png=export.png theta.svg
inkscape --export-id=yellow --export-id-only --export-area-drawing --export-plain-svg=export.svg theta.svg
inkscape --export-id=yellow --export-id-only --export-area-drawing --export-pdf=export.pdf theta.svg
inkscape --export-id=yellow --export-id-only --export-area-drawing --export-ps=export.ps  theta.svg
inkscape --export-id=yellow --export-id-only --export-area-drawing --export-eps=export.eps theta.svg
inkscape --export-id=yellow --export-id-only --export-area-drawing --export-emf=export.emf theta.svg
inkscape --export-id=yellow --export-id-only --export-area-drawing --export-wmf=export.wmf theta.svg

It's interesting that Inkscape 0.92.4 exports PNG well, but other formats are bad (including SVG). @ede123, for PNG mark this issue as regression. Can you fix this part for 1.0?

Inkscape Version and Operating System:

  • Inkscape Version: Inkscape 0.92.4 (5da689c313, 2019-01-14) and Inkscape 1.1-dev (57de80b5, 2020-04-03)
  • Operating System: Ubuntu 19
  • Operating System version: 19.10