Difference between revisions of "Using the Command Line"

From Inkscape Wiki
Jump to navigation Jump to search
(→‎Background: Add info about what Inkscape versions this page applies to.)
Line 34: Line 34:
==Export files==
==Export files==


=== Via export options ===
Use of export options will suppress the GUI. All files listed on the command line will be opened, processed according to export options. and then be closed.
Some options are exclusive.
* If both '''--export-filename''' and '''--export-type''' are given, the file name extension must match the type.
* Only one of '''--export-area''', '''--export-area-page''', '''-export-area-drawing''', '''--export-use-hints''' will be used to determine the export area. (Which one?)
==== Examples ====
* Simple export of a PNG: '''inkscape --export-type="png" my_file.svg'''
* Simple export of a PNG: '''inkscape --export-type="png" my_file.svg'''
: This will produce a PNG with a name '''my_file.png'''
: This will produce a PNG with a name '''my_file.png'''
Line 44: Line 53:
* Export more than one object to SVG files: '''inkscape --export-type="svg" --export-id="MyTriangle,MyRectangle" --export-id-only my_file.svg'''  CRASH: FIXME
* Export more than one object to SVG files: '''inkscape --export-type="svg" --export-id="MyTriangle,MyRectangle" --export-id-only my_file.svg'''  CRASH: FIXME
: This will produce two SVG files, one with just the triangle, the other with just the rectangle.
: This will produce two SVG files, one with just the triangle, the other with just the rectangle.
=== Via actions ===
Use of export options and actions can be mixed. (How?)
If only actions are used, the use of the GUI must explicitly be turned off ('''--without-gui''').
All files on the command line will be opened, processed according to actions options, and then closed. Export can be forced at any point with the '''export-do''' action. This allows one to do multiple exports on a single file.
==== Examples ====
* '''inkscape --without-gui --actions="export-id:MyTriangle; export-id-only; export-background:purple; export-filename:triangle_purple.png; export-do; export-background:red; export-filename:triangle_red.png" my_file.svg'''
: This will export the object with the id '''MyTriangle''' with a purple background to the file '''triangle_purple.png''' and with a red background to the file '''triangle_red.png'''. (Note: there is an implicit file export at the end.

Revision as of 17:52, 25 November 2018

Background

Starting after the release of the 0.92.x series, Inkscape's code is undergoing a major rewrite with the dual goals of making it more powerful and flexible for the user while making it easier for the developer. This is a long term process and it will be awhile before we see the full benefits.

As a first step, we've started to use the latest Gtk 3 application code for Inkscape 1.0 which has resulted in some changes in how the command line works.

For the command line parameters for Inkscape versions up to 0.92.x, please check the corresponding output of inkscape --help on the command line.

What can you do with the command line?

This is (not yet) a complete list.

Print out information

  • Help (list of command line options): inkscape --help or inkscape -?
  • Inkscape version: inkscape --version
  • Extension directory: inkscape --extensions-directory
  • List of available verbs (very long): inkscape --verb-list
  • List of available actions: inkscape --action-list

Query geometry information

  • Find the x position of a set of objects: inkscape --query-id="MyTriangle,MySquare" --query-x my_file.svg
This will return, for example:
200,300
  • Query the geometry of all objects: inkscape --query-all
This will return, for example (id,x,y,width,height):
MySvg,0,0,600,600
MyGroup,100,100,300,300
MyTriangle,120,120,100,80
MySquare,150,150,50,50

Export files

Via export options

Use of export options will suppress the GUI. All files listed on the command line will be opened, processed according to export options. and then be closed.

Some options are exclusive.

  • If both --export-filename and --export-type are given, the file name extension must match the type.
  • Only one of --export-area, --export-area-page, -export-area-drawing, --export-use-hints will be used to determine the export area. (Which one?)

Examples

  • Simple export of a PNG: inkscape --export-type="png" my_file.svg
This will produce a PNG with a name my_file.png
  • Export one object from the file to a PNG: inkscape --export-type="png" --export-id="MyTriangle" my_file.svg
This will produce a PNG with a file name my_file_MyTriangle.png which tightly wraps the object. Objects that extend into the exported area will be shown.
  • Export one object from the file to a PNG, hiding all other objects: inkscape --export-type="png" --export-id="MyTriangle" --export-id-only my_file.svg
This will produce a PNG with a file name my_file_MyTriangle.png which tightly wraps the object. Only the triangle is shown.
  • Export more than one object at a time to PNG files: inkscape --export-type="png" --export-id="MyTriangle,MyRectangle" my_file.svg
This will produce two PNG files, one tightly wrapping the triangle, the other the rectangle.
  • Export more than one object to SVG files: inkscape --export-type="svg" --export-id="MyTriangle,MyRectangle" --export-id-only my_file.svg CRASH: FIXME
This will produce two SVG files, one with just the triangle, the other with just the rectangle.

Via actions

Use of export options and actions can be mixed. (How?) If only actions are used, the use of the GUI must explicitly be turned off (--without-gui). All files on the command line will be opened, processed according to actions options, and then closed. Export can be forced at any point with the export-do action. This allows one to do multiple exports on a single file.

Examples

  • inkscape --without-gui --actions="export-id:MyTriangle; export-id-only; export-background:purple; export-filename:triangle_purple.png; export-do; export-background:red; export-filename:triangle_red.png" my_file.svg
This will export the object with the id MyTriangle with a purple background to the file triangle_purple.png and with a red background to the file triangle_red.png. (Note: there is an implicit file export at the end.