Page 1 of 2 12 LastLast
Results 1 to 10 of 19

Thread: batch convert svg to png

  1. #1
    Join Date
    May 2007
    Beans
    360

    batch convert svg to png

    whats the easiest way to do this? I have a ton of svg i would like to convert, but so far havent found an easy way to do this. I hace access to OSX, XP, and Ubuntu on this box, so whatever OS does it the easiest...
    Thanks for any help, i've googled for an hour and couldnt find anything, so any help is very welcome!

  2. #2
    Join Date
    Oct 2006
    Location
    Belgrade, Serbia
    Beans
    1,321
    Distro
    Ubuntu

    Re: batch convert svg to png

    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=<float>                  pixels per inch [optional; defaults to 90dpi]
      -p, --dpi-y=<float>                  pixels per inch [optional; defaults to 90dpi]
      -x, --x-zoom=<float>                 x zoom factor [optional; defaults to 1.0]
      -y, --y-zoom=<float>                 y zoom factor [optional; defaults to 1.0]
      -z, --zoom=<float>                   zoom factor [optional; defaults to 1.0]
      -w, --width=<int>                    width [optional; defaults to the SVG's width]
      -h, --height=<int>                   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

  3. #3
    Join Date
    May 2007
    Beans
    360

    Re: batch convert svg to png

    I love you.

    Ill get that package and give it a shot. Thank you so much

  4. #4
    Join Date
    Jul 2007
    Beans
    396

    Re: batch convert svg to png

    Quote Originally Posted by NoSmokingBandit View Post
    I love you.

    Ill get that package and give it a shot. Thank you so much
    I know wow... this is great.

  5. #5
    Join Date
    May 2007
    Beans
    360

    Re: batch convert svg to png

    apt-get cant find that package for me, what repo is it in? Im on kubuntu 8.04 and have all the standard repos enabled.

  6. #6
    Join Date
    Oct 2007
    Location
    Crete, Greece
    Beans
    117
    Distro
    Kubuntu 12.04 Precise Pangolin

    Re: batch convert svg to png

    If you want a GUI, how about Phatch?
    It can do a lot more than simple conversion too.
    http://photobatch.stani.be/

  7. #7
    Join Date
    Aug 2006
    Location
    Lovely Wangen bei Olten
    Beans
    288
    Distro
    Ubuntu 8.04 Hardy Heron

    Re: batch convert svg to png

    Hi forger, could you help to change your nice little script to a whole file structure with directories and subdirectories?

    Code:
    for i in *; do rsvg-convert $i -o `echo $i | sed -e 's/svg$/png/'`; done
    Thanks!
    --- borobudur ---

  8. #8
    Join Date
    Oct 2006
    Location
    Belgrade, Serbia
    Beans
    1,321
    Distro
    Ubuntu

    Re: batch convert svg to png

    use find:
    Code:
    myfolder=/path/to/your/folder
    for i in `find $myfolder -depth -name '*.svg'`; do rsvg-convert $i -o `echo $i | sed -e 's/svg$/png/'`; done
    The code above is not tested, I just assume that *it should* work

    In ubuntu 8.04.1 (hardy heron) or 8.10 (intrepid ibex) you have phatch:
    Code:
    sudo apt-get install phatch

  9. #9
    Join Date
    Oct 2006
    Location
    Belgrade, Serbia
    Beans
    1,321
    Distro
    Ubuntu

    Re: batch convert svg to png

    Quote Originally Posted by NoSmokingBandit View Post
    apt-get cant find that package for me, what repo is it in? Im on kubuntu 8.04 and have all the standard repos enabled.
    a bit late answer, but:
    http://packages.ubuntu.com/librsvg2-bin

  10. #10
    Join Date
    Aug 2006
    Location
    Lovely Wangen bei Olten
    Beans
    288
    Distro
    Ubuntu 8.04 Hardy Heron

    Re: batch convert svg to png

    Quote Originally Posted by forger View Post
    use find:
    Code:
    myfolder=/path/to/your/folder
    for i in `find $myfolder -depth -name '*.svg'`; do rsvg-convert $i -o `echo $i | sed -e 's/svg$/png/'`; done
    The code above is not tested, I just assume that *it should* work

    In ubuntu 8.04.1 (hardy heron) or 8.10 (intrepid ibex) you have phatch:
    Code:
    sudo apt-get install phatch
    Thanks!
    --- borobudur ---

Page 1 of 2 12 LastLast

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •