Opções na Linha de Comando
Introdução
Assim como muitos outros programas você pode usar o Inkscape pela linha de comando, automatizando vários processos simples e repetitivos de conversão de formatos ou coleta de informação.
* Esclarecendo: você não abre a janela, mas ainda assim o executa em modo não interativo.
Notou o
ls? Ele mostra os arquivos do diretório (No caso filtramos só os arquivos com nome
teste).
Alí vemos que o PDF foi criado. Se ainda não acredita abra-o no seu leitor de PDF.
Se você não está acostumado com a linha de comando, teste esse exemplo no seu terminal:
inkscape --export-pdf=teste.pdf teste.svg
Com essa linha você gera o arquivo
teste.pdf a partir da ilustração
teste.svg sem precisar abrir
* o Inkscape.
Na linha de comando a primeira palavra é o comando e, em geral, o comando é o nome de um programa, no caso, o
inkscape é o comando.
Cada conjunto de caracteres separados por espaços é um argumento passado ao programa, informando o que ele deve fazer. Os programas entendem os argumentos da forma que o desenvolvedor definir, mas para facilitar a vida dos usuários os desenvolvedores de SL, em geral, seguem o padrão GNU de nomeação de argumentos. Por isso você passa argumentos para o Inkscape da mesma forma que passa para a maioria dos outros programas usados no GNU/Linux e UNIXes em geral.
No exemplo passamos dois argumentos:
--export-pdf=teste.pdf e
teste.svg.
O argumento
--export-pdf=teste.pdf tem o nome extenso e é do tipo
--nome=valor, poderíamos usar a forma simplificada:
-A teste.pdf, onde o argumento seguinte é o valor do primeiro.
Nesse caso a linha de comando ficaria assim:
inkscape -A teste.pdf teste.svg
O Inkscape agiria exatamente da mesma forma, mas o argumento
-A não é auto-explicativo como o
--export-pdf, por isso a forma simplificada é usada no terminal para escrita rápida, mas não em scripts onde outras pessoas gostariam de avaliar o código.
Se o último argumento, é apenas o nome de um arquivo o Inkscape subentende que este é o
SVG no qual ele deve trabalhar.
Opções
-? ou --help
Mostra um texto de ajuda no terminal.
-V ou --version
Mostra a versão e data de compilação.
-a x0:y0:x1:y1 ou --export-area=x0:y0:x1:y1
Na exportação de PNGs esse atributo define a área a ser exportada em unidades do usuário
(O
SVG do Inkscape normalmente usa unidades anônimas).
O padrão é exportar toda a página do documento.
O ponto
0,0 é o canto inferior esquerdo.
Exemplos:
Temos este o arquivo
teste.svg:
inkscape --export-png=teste.png teste.svg
Gera:
(com export-area indefinido pegamos toda a página)
inkscape --export-png=teste_c1.png -a 0:0:100:100 teste.svg
Gera:
inkscape --export-png=teste_c2.png -a 30:30:120:120 teste.svg
Gera:
-C ou --export-area-canvas
Define toda a página como área a ser exportada para um PNG ou PDF.
Normalmente isso é o padrão, então você não precisa especificar isso,
a não ser que esteja usando
--export-id para exportar um elemento específico.
-D ou --export-area-drawing
Define toda a área desenhada
(não a página) como área a ser exportada para um PNG ou PDF,
ou seja, exporta o retângulo de seleção que contém todos os elementos visíveis no
SVG.
Para o PNG, pode-se combinar com
--export-use-hints.
--export-area-snap
For PNG export, snap the export area outwards to the nearest
integer
SVG user unit (px) values. If you are using the default
export resolution of 90dpi and your graphics are pixel-snapped
to minimize antialiasing, this switch allows you to preserve
this alignment even if you are exporting some object’s bounding
box (with --export-id or --export-area-drawing) which is itself
not pixel-aligned.
-b COLOR ou --export-background=COLOR
Background color of exported PNG. This may be any
SVG
supported color string, for example "#ff007f" or "rgb(255, 0,
128)". If not set, then the page color set in Inkscape in the
Document Options dialog will be used (stored in the pagecolor=
attribute of sodipodi:namedview).
-d DPI ou --export-dpi=DPI
The resolution used for PNG export. The default is 90, which
corresponds to 1
SVG user unit (px, also called "user unit")
exporting to 1 bitmap pixel. This value overrides the DPI hint
if used with --export-use-hints.
-e FILENAME ou --export-png=FILENAME
Specify the filename for PNG export. If it already exists, the
file will be overwritten without asking.
-f FILENAME ou --file=FILENAME
Open specified document(s). Option string may be omitted, i.e.
you can list the filenames without -f.
-g ou --with-gui
Try to use the GUI (on Unix, use the X server even if $DISPLAY
is not set).
-h HEIGHT ou --export-height=HEIGHT
The height of generated bitmap in pixels. This value overrides
the --export-dpi setting (or the DPI hint if used with
--export-use-hints).
-i ID ou --export-id=ID
For PNG and PDF export, the id attribute value of the object
that you want to export from the document. By default the
exported area is the bounding box of the object; you can
override this using --export-area, --export-area-canvas, or
--export-area-drawing.
-j ou --export-id-only
Only export to PNG the object whose id is given in --export-id.
All other objects are hidden and won’t show in export even if
they overlay the exported object. Without --export-id, this
option is ignored. For PDF export, this is the default, so this
option has no effect.
-l ou --export-plain-svg=FILENAME
Export document(s) to plain
SVG format, without sodipodi: or
inkscape: namespaces and without RDF metadata.
-x ou --extension-directory
Lists the current extension directory that Inkscape is
configured to use and then exits. This is used for external
extension to use the same configuration as the original
Inkscape installation.
--verb-list
Lists all the verbs that are available in Inkscape by ID. This
ID can be used in defining keymaps or menus. It can also be
used with the --verb command line option.
--verb=VERB-ID ou --select=OBJECT-ID
These two options work together to provide some basic scripting
for Inkscape from the command line. They both can occur as
many times as needed on the command line and are executed in
order on every document that is specified.
The --verb command will execute a specific verb as if it was
called from a menu or button. Dialogs will appear if that is
part of the verb. To get a list of the verb IDs available, use
the --verb-list command line option.
The --select command will cause objects that have the ID
specified to be selected. This allows various verbs to act
upon them. To remove all the selections use
--verb=EditDeselect. The object IDs available are dependent on
the document specified to load.
-p PRINTER ou --print=PRINTER
Print document(s) to the specified printer using ‘lpr -P
PRINTER’. Alternatively, use ‘| COMMAND’ to specify a
different command to pipe to, or use ‘> FILENAME’ to write the
PostScript? output to a file instead of printing. Remember to
do appropriate quoting for your shell, e.g.
inkscape --print=’| ps2pdf - mydoc.pdf’ mydoc.svg
-t ou --export-use-hints
Use export filename and DPI hints stored in the exported object
(only with --export-id). These hints are set automatically
when you export selection from within Inkscape. So, for
example, if you export a shape with id="path231" as
/home/me/shape.png at 300 dpi from document.svg using Inkscape
GUI, and save the document, then later you will be able to
reexport that shape to the same file with the same resolution
simply with
inkscape -i path231 -t document.svg
If you use --export-dpi, --export-width, or --export-height
with this option, then the DPI hint will be ignored and the
value from the command line will be used. If you use
--export-png with this option, then the filename hint will be
ignored and the filename from the command line will be used.
-w WIDTH ou --export-width=WIDTH
The width of generated bitmap in pixels. This value overrides
the --export-dpi setting (or the DPI hint if used with
--export-use-hints).
-y VALUE ou --export-background-opacity=VALUE
Opacity of the background of exported PNG. This may be a value
either between 0.0 and 1.0 (0.0 meaning full transparency, 1.0
full opacity) or greater than 1 up to 255 (255 meaning full
opacity). If not set and the -b option is not used, then the
page opacity set in Inkscape in the Document Options dialog
will be used (stored in the inkscape:pageopacity= attribute of
sodipodi:namedview). If not set but the -b option is used,
then the value of 255 (full opacity) will be used.
-P FILENAME ou --export-ps=FILENAME
Export document(s) to
PostScript? format. Note that
PostScript?
does not support transparency, so any transparency in the
original
SVG will be lost. This option can be used together
with --export-bbox-page and --export-text-to-path.
-E FILENAME ou --export-eps=FILENAME
Export document(s) to Encapsulated
PostScript? format. Note that
PostScript? does not support transparency, so any transparency
in the original
SVG will be lost. This option can be used
together with --export-bbox-page and --export-text-to-path.
-A FILENAME ou --export-pdf=FILENAME
Export document(s) to PDF 1.4 format. This format preserves the
transparency in the original
SVG (though not all PDF viewers
can display it yet). This option can be used together with
--export-text-to-path (currently this is required, because
exporting text as text is not yet supported).
By default, the entire document is exported and the page size
of the PDF is that of the
SVG document. You can specify
--export-id to export a single object (with PDF page the size
of that object’s bounding box) and --export-area-drawing to
make the exported PDF page show the entire drawing (by default
the
SVG page).
-T ou --export-text-to-path
Convert text objects to paths on export, where applicable
(currently works for PS, EPS, and PDF export).
-B ou --export-bbox-page
Export files with the bounding box set to the page size, where
applicable (currently works for PS and EPS export).
-F ou --export-embed-fonts
Embed fonts used in the document into exported PS/EPS file.
Note: only Type 1 fonts can be embedded, not
TrueType? .
-I ou --query-id
Set the ID of the object whose dimensions are queried. If not
set, query options will return the dimensions of the drawing
(i.e. all document objects), not the page or viewbox
-X ou --query-x
Query the X coordinate of of the drawing or, if specified, of
the object with --query-id. The returned value is in px (
SVG
user units).
-Y ou --query-y
Query the Y coordinate of of the drawing or, if specified, of
the object with --query-id. The returned value is in px (
SVG
user units).
-W ou --query-width
Query the width of of the drawing or, if specified, of the
object with --query-id. The returned value is in px (
SVG user
units).
-H ou --query-height
Query the height of of the drawing or, if specified, of the
object with --query-id. The returned value is in px (
SVG user
units).
-S ou --query-all
Prints a comma delimited listing of all objects in the
SVG
document with IDs defined, along with their x, y, width, and
height values.
--vacuum-defs
Remove all unused items from the
defs section of the
SVG file. If this option is invoked in conjunction with
--export-plain-svg, only the exported file will be affected.
If it is used alone, the specified file will be modified in
place.
-z ou --without-gui
Do not open the GUI (on Unix, do not use X server); only
process the files from console. This is assumed for -p, -e,
-l, and --vacuum-defs options.
--g-fatal-warnings
Part of the standard GTK option that are recognized. This
forces any GTK warnings to cause Inkscape to abort. This
option is listed because it gets used for debugging.
--usage
Display a brief usage message.
Referências
Man Page do Inkscape.
Comentarios