1RSVG-CONVERT()                                                  RSVG-CONVERT()
2
3
4

NAME

6       rsvg-convert  -  Render SVG documents to PNG images, or convert them to
7       PDF or PS.
8

SYNOPSIS

10       Convert an SVG to PNG at its "natural size" and write  it  to  standard
11       output:
12          rsvg-convert input.svg > output.png
13
14       Specify  an  output filename; the input filename must be the last argu‐
15       ment:
16          rsvg-convert --output=output.png input.svg
17
18       Configure dots-per-inch (DPI) for SVGs that have physical units, as  in
19       <svg width="5cm" height="3cm"> - the default is 96 DPI:
20          rsvg-convert --dpi-x=300 --dpi-y=300 input.svg > output.png
21
22       Render an SVG at a specific pixel size, scaled proportionally:
23          rsvg-convert --width=1024 --height=768 --keep-aspect-ratio input.svg
24          > output.png
25

DESCRIPTION

27       rsvg-convert renders SVG documents into PNG raster images, or  converts
28       them  to PDF or PS as vector objects. By default rsvg-convert will ren‐
29       der an SVG document to a raster PNG image and write it to standard out‐
30       put:
31          rsvg-convert input.svg > output.png
32
33       To select another format, use the --format option:
34          rsvg-convert --format=pdf input.svg > output.pdf
35
36       You can use rsvg-convert as part of a pipeline; without an argument for
37       the input filename it will read the document from standard input:
38          cat input.svg | rsvg-convert > output.png
39
40   SPECIFYING THE RENDERED SIZE
41       You can use the --width and --height options to specify the size of the
42       output  image.  Most of the time you should specify --keep-aspect-ratio
43       to scale the image proportionally; for compatibility with old  versions
44       this is not the default.
45          rsvg-convert  --width=100 --height=200 --keep-aspect-ratio input.svg
46          > output.png
47
48       You can also specify dimensions as CSS lengths,  for  example  10px  or
49       8.5in. The unit specifiers supported are as follows:
50
51                           ┌───┬────────────────────────────┐
52                           │px │ pixels (the unit specifier │
53                           │   │ can be omitted)            │
54                           ├───┼────────────────────────────┤
55                           │in │ inches                     │
56                           ├───┼────────────────────────────┤
57                           │cm │ centimeters                │
58                           ├───┼────────────────────────────┤
59                           │mm │ millimeters                │
60                           ├───┼────────────────────────────┤
61                           │pt │ points, 1/72 inch          │
62                           ├───┼────────────────────────────┤
63                           │pc │ picas, 1/6 inch            │
64                           └───┴────────────────────────────┘
65
66       The following will create a 600*900 pixel PNG, or  2*3  inches  at  300
67       dots-per-inch:
68          rsvg-convert     --width=2in     --height=3in    --keep-aspect-ratio
69          --dpi-x=300 --dpi-y=300 input.svg > output.png
70
71       This will scale an SVG document to fit in an A4 page and convert it  to
72       PDF:
73          rsvg-convert  --format=pdf  --width=210mm  --height=297mm --keep-as‐
74          pect-ratio input.svg > output.pdf
75
76   SPECIFYING A PAGE SIZE
77       By default the size of the output comes from the rendered  size,  which
78       can  be  specified  with  the --width and --height options, but you can
79       specify  a  page  size  independently  of  the   rendered   size   with
80       --page-width  and --page-height, together with --top and --left to con‐
81       trol the position of the rendered image within the page.  In short:
82
83--page-width and --page-height together - set the page size.
84
85--top and --left - set the margins.
86
87--width and --height - set the rendered size.
88
89       This will create a PDF with a landscape A4 page, by scaling an SVG doc‐
90       ument  to  10*10  cm, and placing it with its top-left corner 5 cm away
91       from the top and 8 cm from the left of the page:
92          rsvg-convert  --format=pdf  --page-width=297mm   --page-height=210mm
93          --width=10cm  --height=10cm --keep-aspect-ratio --top=5cm --left=8cm
94          input.svg > output.pdf
95
96   SPECIFYING A SCALE FACTOR INSTEAD OF A RENDERED SIZE
97       The --zoom option lets you scale the natural size of an  SVG  document.
98       For example, if input.svg is a document with a declared size of 100*200
99       pixels, then the following command will render  it  at  250*500  pixels
100       (zoom 2.5):
101          rsvg-convert --zoom=2.5 input.svg > output.png
102
103       You  can  limit  the  maximum scaled size by specifying the --width and
104       --height options together with --zoom.  Here, the image will be  scaled
105       10x, but limited to 1000*1000 pixels at the most:
106          rsvg-convert  --zoom=10  --width=1000 --height=1000 input.svg > out‐
107          put.png
108
109       If you need different scale factors for the horizontal and vertical di‐
110       mensions, use the --x-zoom and --y-zoom options instead of --zoom.
111
112   CREATING A MULTI-PAGE DOCUMENT
113       The "pdf", "ps", and "eps" output formats support multiple pages. These
114       can be created by combining multiple input SVG files. For example, this
115       PDF file will have three pages:
116          rsvg-convert --format=pdf page1.svg page2.svg page3.svg > out.pdf
117
118       The size of each page will be computed, separately, as described in the
119       DEFAULT OUTPUT SIZE section. This may result in a  PDF  being  produced
120       with  differently-sized  pages.  If  you need to produce a PDF with all
121       pages  set  to  exactly  the  same  size,  use  the  --page-width   and
122       --page-height options.
123
124       For  example,  the  following  command  creates a three-page PDF out of
125       three SVG documents. All the pages are portrait US Letter, and each SVG
126       is  scaled to fit so that there is a 1in margin around each page (hence
127       the width of 6.5in and height of 9in for the rendered size).
128          rsvg-convert  --format=pdf   --page-width=8.5in   --page-height=11in
129          --width=6.5in  --height=9in --keep-aspect-ratio --top=1in --left=1in
130          pg1.svg pg2.svg pg3.svg > out.pdf
131
132   CONVERSION OF PIXELS BASED ON THE DOTS-PER-INCH
133       rsvg-convert uses the --dpi-x and  --dpi-y  options  to  configure  the
134       dots-per-inch  (DPI) by which pixels will be converted to/from physical
135       units like inches or centimeters. The default for both  options  is  96
136       DPI.
137
138       Consider this example SVG, which is nominally declared to be 2*3 inches
139       in size:
140
141          <svg xmlns="http://www.w3.org/2000/svg" width="2in" height="3in">
142            <!-- graphical objects here -->
143          </svg>
144
145       The following commands create PNGs of different sizes for  the  example
146       SVG above:
147          rsvg-convert  two-by-three.svg  >  output.png #### creates a 192*288
148          pixel PNG
149
150          rsvg-convert --dpi-x=300 --dpi-y=300 two-by-three.svg  >  output.png
151          #### creates a 600*900 pixel PNG
152
153       Note  that  the  final  pixel  dimensions are rounded up to the nearest
154       pixel, to avoid clipping off the right/bottom edges. In  the  following
155       example, rsvg-convert will generate a PNG 300x300 pixels in size:
156          rsvg-convert  --width=299.5  --height=299.4  input.svg  > output.png
157          #### outputs 300x300 pixel PNG with a fractionally-scaled image
158
159       If you specify dimensions in physical units, they will be multiplied by
160       the dots-per-inch (DPI) value to obtain dimensions in pixels. For exam‐
161       ple, this will generate a 96x96 pixel PNG, since it is 1x1 inch at  the
162       default 96 DPI:
163          rsvg-convert  --width=1in  --height=1in  input.svg > output.png ####
164          outputs 96x96 pixel PNG
165
166       Correspondingly, this will generate a 300x300 pixel PNG,  since  it  is
167       1x1 inch at 300 DPI:
168          rsvg-convert  --width=1in  --height=1in  --dpi-x=300 --dpi-y=300 in‐
169          put.svg > output.png #### outputs 300x300 pixel PNG
170
171   DEFAULT OUTPUT SIZE
172       If you do not specify --width or --height options for the output  size,
173       rsvg-convert will figure out a "natural size" for the SVG as follows:
174
175SVG  with  width  and  height  in pixel units (px): <svg width="96px"
176         height="192px"> For PNG output, those same dimensions in  pixels  are
177         used.  For PDF/PS/EPS, that pixel size is converted to physical units
178         based on the DPI value (see the --dpi-x and --dpi-y options),
179
180SVG with  width  and  height  in  physical  units:  <svg  width="1in"
181         height="2in">  For  PNG  output,  the width and height attributes get
182         converted to pixels, based on the DPI  value  (see  the  --dpi-x  and
183         --dpi-y options). For PDF/PS/EPS output, the width/height in physical
184         units define the size of the PDF unless you specify options  for  the
185         page size; see SPECIFYING A PAGE SIZE above.
186
187SVG  with  viewBox  only:  <svg  viewBox="0 0 20 30"> The size of the
188         viewBox attribute gets used for the pixel size of the image as in the
189         first case above.
190
191SVG   with   width  and  height  in  percentages:  <svg  width="100%"
192         height="100%" viewBox="0 0 20 30"> Percentages are meaningless unless
193         you specify a viewport size with the --width and --height options. In
194         their absence, rsvg-convert will just use the size of the viewBox for
195         the pixel size, as described above.
196
197SVG  with no width, height, or viewBox: rsvg-convert will measure the
198         extents of all graphical objects in the SVG document and render  them
199         at  1:1  scale  (1 pixel for each CSS px unit). It is strongly recom‐
200         mended that you give SVG documents an explicit size with  the  width,
201         height, or viewBox attributes.
202
203   BACKGROUND COLOR
204       You can use the --background-color option (-b for short) to specify the
205       background color that will appear in parts of the image that would oth‐
206       erwise  be  transparent. This option accepts the same syntax as the CSS
207       color property, so you can use #rrggbb syntax, or CSS named colors like
208       white, or rgba().
209          rsvg-convert  --background-color=white  input.svg  > output.png ####
210          opaque white
211          rsvg-convert -b '#ff000080' input.svg > output.png ####  translucent
212          red - use shell quotes so the # is not interpreted as a comment
213
214   SELECTING A LANGUAGE FOR MULTI-LANGUAGE SVG
215       An SVG document can use the <switch> element and children with the sys‐
216       temLanguage attribute to provide different  content  depending  on  the
217       user's language. For example:
218
219          <svg xmlns="http://www.w3.org/2000/svg" width="200" height="100">
220            <rect width="200" height="100" fill="white"/>
221            <g transform="translate(30, 30)" font-size="20">
222              <switch allowReorder="yes">
223                <text systemLanguage="es">Español</text>
224                <text systemLanguage="de">Deutsch</text>
225                <text systemLanguage="fr">Français</text>
226                <text>English fallback</text>
227              </switch>
228            </g>
229          </svg>
230
231       You  can  use  the --accept-language option to select which language to
232       use when rendering. This option accepts strings formatted like an  HTTP
233       Accept-Language  header,  which is a comma-separated list of BCP47 lan‐
234       guage tags: https://www.rfc-editor.org/info/bcp47
235          rsvg-convert --accept-language=es-MX input.svg > output.png #### se‐
236          lects Mexican Spanish; renders "Español".
237
238   USER STYLESHEET
239       You  can  include  an extra CSS stylesheet to be used when rendering an
240       SVG document with the --stylesheet option. The stylesheet will have the
241       CSS  user  origin,  while styles declared in the SVG document will have
242       the CSS author origin.
243          rsvg-convert --stylesheet=extra-styles.css input.svg > output.png
244
245       Please note that per the cascading rules of CSS, a user stylesheet does
246       not  necessarily  override  the  styles defined in an SVG document.  To
247       override them reliably, you need to set your extra  styles  to  !impor‐
248       tant.
249
250       According       to       the      CSS      Cascading      specification
251       (https://www.w3.org/TR/css-cascade-4/#cascade-sort), style declarations
252       have  the following precedence.  Declarations from origins later in the
253       list win over declarations from earlier origins:
254
255       • Normal user agent declarations (librsvg's own stylesheets).
256
257       • Normal user declarations (from your user stylesheet).
258
259       • Normal author declarations (from the SVG document).
260
261!important author declarations (from the SVG document).
262
263!important user declarations (from your user stylesheet).
264
265!important user agent declarations (librsvg's own stylesheets).
266
267       After that, the CSS specificity and order of appearance of declarations
268       get taken into account.
269
270       Consider   the  following  input.svg;  notice  how  the  rectangle  has
271       fill="red" as a presentation attribute, and a recolorable class:
272
273          <svg xmlns="http://www.w3.org/2000/svg" width="100" height="100">
274            <rect width="200" height="100" fill="white"/>
275
276            <rect class="recolorable" x="10" y="10" width="50" height="50" fill="red"/>
277
278            <text x="10" y="80" font-size="20" fill="red">Hello</text>
279          </svg>
280
281       And this is extra-styles.css:
282
283          .recolorable { fill: blue !important; }
284
285          text { fill: green !important; }
286
287       Then the PNG created by the command above will have these elements:
288
289       • A blue square instead of a red one, because of the selector  for  the
290         the  recolorable class.  The fill: blue !important; declaration takes
291         precendence over the fill="red" presentation attribute.
292
293       • Text in green, since its fill="red" gets overriden with  fill:  green
294         !important.
295

OPTIONS

297   GENERAL OPTIONS
298       -f format, --format=[png, pdf, ps, eps, svg]
299              Output format for the rendered document. Default is png.
300
301       -o filename, --output filename
302              Specify the output filename. If unspecified, outputs to standard
303              output.
304
305       -v, ``--version
306              Display what version of rsvg-convert you are running.
307
308       --help Display a summary of usage and options.
309
310   SIZE AND POSITION
311       In the following, <length> values must be specified with  CSS  <length>
312       syntax:  https://developer.mozilla.org/en-US/docs/Web/CSS/length.   For
313       example, 640px or 25cm.
314
315       --page-width <length> --page-height <length>
316              Page size of the output document; both options must be used  to‐
317              gether.   The  default is to use the image's width and height as
318              modified by the options below.
319
320       --top <length>
321              Distance between top edge of the page and  the  rendered  image.
322              Default is 0.
323
324       --left <length>
325              Distance  between  left edge of the page and the rendered image.
326              Default is 0.
327
328       -w <length>, --width <length>
329              Width of the rendered image. If unspecified, the  natural  width
330              of the image is used as the default. See the section "SPECIFYING
331              DIMENSIONS" above for details.
332
333       -h <length>, --height <length>
334              Height of the rendered image. If unspecified, the natural height
335              of the image is used as the default. See the section "SPECIFYING
336              DIMENSIONS" above for details.
337
338       -a, --keep-aspect-ratio
339              Specify that the aspect ratio is to be preserved, i.e. the image
340              is  scaled proportionally to fit in the --width and --height. If
341              not specified, aspect ratio will not be preserved.
342
343       -d number, --dpi-x number
344              Set the X resolution of the image in pixels per inch. Default is
345              96 DPI.
346
347       -p number, --dpi-y number
348              Set the Y resolution of the image in pixels per inch. Default is
349              96 DPI.
350
351       -x number, --x-zoom number
352              Horizontal scaling factor. Default is 1.0.
353
354       -y number, --y-zoom number
355              Vertical factor factor. Default is 1.0.
356
357       -z number, --zoom number
358              Horizontal and vertical scaling factor. Default is 1.0.
359
360   CONTROLLING THE RENDERED APPEARANCE
361       -b <color>, --background-color [black, white, #abccee, #aaa...]
362              Specify the background color. If unspecified, none  is  used  as
363              the  default;  this  will create transparent PNGs, or PDF/PS/EPS
364              without a special background.  The <color> must be specified  in
365              CSS                        <color>                       syntax:
366              https://developer.mozilla.org/en-US/docs/Web/CSS/color_value.
367              For example, black, #ff0000, rgba(0.0, 1.0, 0.0, 1.0).
368
369       -s filename.css, --stylesheet filename.css
370              Filename of a custom CSS stylesheet.
371
372       -l language-tag, --accept-language [es-MX,fr,en]
373              Specify which languages will be used for SVG documents with mul‐
374              tiple languages. The  string  is  formatted  like  an  HTTP  Ac‐
375              cept-Language  header,  which is a comma-separated list of BCP47
376              language tags:  https://www.rfc-editor.org/info/bcp47.  The  de‐
377              fault is to use the language specified by environment variables;
378              see the section "ENVIRONMENT VARIABLES" below.
379
380   OPTIONS SPECIFIC TO PDF/PS/EPS OUTPUT
381       --keep-image-data
382              For SVG documents that reference PNG or JPEG images, include the
383              original, compressed images in the final output, rather than un‐
384              compressed RGB data. This is the default behavior  for  PDF  and
385              (E)PS output.
386
387       --no-keep-image-data
388              Do not include the original, compressed images but instead embed
389              uncompressed RGB date in PDF or (E)PS  output.  This  will  most
390              likely result in larger documents that are slower to read.
391
392   MISCELLANEOUS
393       -i object-id, --export-id object-id
394              Allows to specify an SVG object that should be exported based on
395              its XML id attribute. If not specified, all objects will be  ex‐
396              ported.
397
398       -u, --unlimited
399              The XML parser has some guards designed to mitigate large CPU or
400              memory consumption in the face of malicious  documents.  It  may
401              also  refuse  to  resolve data: URIs used to embed image data in
402              SVG documents. If you are running into such issues when convert‐
403              ing a SVG, this option allows to turn off these guards.
404
405       --testing
406              For developers only: render images for librsvg's test suite.
407
408       --completion shell-name
409              Generate  a  script  for  a shell's Tab completion.  You can use
410              bash, elvish, fish, powershell, and zsh for  the  shell's  name.
411              Rsvg-convert  will then write a suitable script to standard out‐
412              put.
413

ENVIRONMENT VARIABLES

415       SOURCE_DATE_EPOCH
416              If the selected output format is PDF, this variable can be  used
417              to  control the CreationDate in the PDF file. This is useful for
418              reproducible output. The environment variable must be set  to  a
419              decimal number corresponding to a UNIX timestamp, defined as the
420              number of seconds, excluding leap seconds,  since  01  Jan  1970
421              00:00:00  UTC.  The  specification  for  this  can  be  found at
422              https://reproducible-builds.org/specs/source-date-epoch/
423
424       System language
425              Unless the --accept-language option is specified, the default is
426              to  use  the system's environment to detect the user's preferred
427              language. This  consults  the  environment  variables  LANGUAGE,
428              LC_ALL, LC_MESSAGES, and LANG.
429

MORE INFORMATION

431       Librsvg       source       repository       and       bug      tracker:
432       https://gitlab.gnome.org/GNOME/librsvg
433
434       Wiki project page: https://wiki.gnome.org/Projects/LibRsvg
435
436       SVG1.1 specification: http://www.w3.org/TR/SVG11/
437
438       SVG2 specification: http://www.w3.org/TR/SVG2
439
440       GNOME project page: http://www.gnome.org/
441
442
443
444
445                                                                RSVG-CONVERT()
Impressum