Skip to main content

batch convert svg to png

http://gengwg.blogspot.com/
I just opened gnome-terminal and searched:
Code:
$ apt-cache search svg.*png
inkscape - vector-based drawing program
librsvg2-bin - command-line and graphical viewers for SVG files
scribus - Open Source Desktop Page Layout
...
my eye caught librsvg2-bin
Code:
$ apt-cache show librsvg2-bin
...
Description: command-line and graphical viewers for SVG files
 The rsvg library is an efficient renderer for Scalable Vector Graphics
 (SVG) pictures.
 .
 This package includes a command-line utility to convert the SVG files
 to the PNG format and a graphical SVG viewer.
afterwards, i checked out the package to see the command for it:
Code:
$ sudo apt-get install librsvg2-bin
...

$ dpkg -L librsvg2-bin
...
/usr/bin/rsvg-convert
/usr/bin/rsvg-view
/usr/bin/rsvg
...
Cool, now we know the commands included
Code:
$ rsvg-convert --help
Usage:
  rsvg-convert [OPTION...] [FILE...] - SVG Converter
Help Options:
  -?, --help                           Show help options
Application Options:
  -d, --dpi-x=                  pixels per inch [optional; defaults to 90dpi]
  -p, --dpi-y=                  pixels per inch [optional; defaults to 90dpi]
  -x, --x-zoom=                 x zoom factor [optional; defaults to 1.0]
  -y, --y-zoom=                 y zoom factor [optional; defaults to 1.0]
  -z, --zoom=                   zoom factor [optional; defaults to 1.0]
  -w, --width=                    width [optional; defaults to the SVG's width]
  -h, --height=                   height [optional; defaults to the SVG's height]
  -f, --format=[png, pdf, ps, svg]     save format [optional; defaults to 'png']
  -o, --output                         output filename [optional; defaults to stdout]
  -a, --keep-aspect-ratio              whether to preserve the aspect ratio [optional; defaults to FALSE]
  -v, --version                        show version information
  -b, --base-uri                       base uri
With some bash scripting you have a script:
Code:
$ cd your-directory-with-the-svgs/
$ for i in *; do rsvg-convert $i -o `echo $i | sed -e 's/svg$/png/'`; done
cheers!

P.S. you can do a similar conversion using inkscape's command line:
Code:
$ cd your-directory-with-the-svgs/
$ for i in *; do inkscape $i --export-png=`echo $i | sed -e 's/svg$/png/'`; done

Comments

Popular posts from this blog

CKA Simulator Kubernetes 1.22

  https://killer.sh Pre Setup Once you've gained access to your terminal it might be wise to spend ~1 minute to setup your environment. You could set these: alias k = kubectl                         # will already be pre-configured export do = "--dry-run=client -o yaml"     # k get pod x $do export now = "--force --grace-period 0"   # k delete pod x $now Vim To make vim use 2 spaces for a tab edit ~/.vimrc to contain: set tabstop=2 set expandtab set shiftwidth=2 More setup suggestions are in the tips section .     Question 1 | Contexts Task weight: 1%   You have access to multiple clusters from your main terminal through kubectl contexts. Write all those context names into /opt/course/1/contexts . Next write a command to display the current context into /opt/course/1/context_default_kubectl.sh , the command should use kubectl . Finally write a second command doing the same thing into ...

OWASP Top 10 Threats and Mitigations Exam - Single Select

Last updated 4 Aug 11 Course Title: OWASP Top 10 Threats and Mitigation Exam Questions - Single Select 1) Which of the following consequences is most likely to occur due to an injection attack? Spoofing Cross-site request forgery Denial of service   Correct Insecure direct object references 2) Your application is created using a language that does not support a clear distinction between code and data. Which vulnerability is most likely to occur in your application? Injection   Correct Insecure direct object references Failure to restrict URL access Insufficient transport layer protection 3) Which of the following scenarios is most likely to cause an injection attack? Unvalidated input is embedded in an instruction stream.   Correct Unvalidated input can be distinguished from valid instructions. A Web application does not validate a client’s access to a resource. A Web action performs an operation on behalf of the user without checkin...