Is there a way to batch export SVGs to PNGs?












17















I have these SVGS and I'd like to export them to PNG images, I could export them with Inkscape but that would mean open each file and export that file to PNG which is not efficient (I have hundreds of them).



How can I do this?










share|improve this question





























    17















    I have these SVGS and I'd like to export them to PNG images, I could export them with Inkscape but that would mean open each file and export that file to PNG which is not efficient (I have hundreds of them).



    How can I do this?










    share|improve this question



























      17












      17








      17


      7






      I have these SVGS and I'd like to export them to PNG images, I could export them with Inkscape but that would mean open each file and export that file to PNG which is not efficient (I have hundreds of them).



      How can I do this?










      share|improve this question
















      I have these SVGS and I'd like to export them to PNG images, I could export them with Inkscape but that would mean open each file and export that file to PNG which is not efficient (I have hundreds of them).



      How can I do this?







      convert inkscape png svg






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Jan 29 '14 at 13:50









      Glutanimate

      16.3k874132




      16.3k874132










      asked Oct 30 '12 at 3:46









      Uri HerreraUri Herrera

      10.4k1574130




      10.4k1574130






















          5 Answers
          5






          active

          oldest

          votes


















          16














          Inspired by the previously accepted answer I came up with this one-liner:



          for file in *.svg; do inkscape $file -e ${file%svg}png; done


          This way you don't need to call a script. If you wanted to, you could create an alias for converting all svgs in the current directory to pngs:



          alias svgtopng='for file in *.svg; do inkscape $file -e ${file%svg}png; done'





          share|improve this answer





















          • 1





            ${file%svg}png is a great trick! I had not seen that before.

            – Chester
            Jan 19 '17 at 20:49



















          24














          It appears you can use Inkscape from command line:



          `#{INKSCAPE_PATH} -z -f #{source_svg} -w #{width} -j -e #{dest_png}`


          more details



          I imagine you can write a simple bash script to process all SVG files:



          #!/bin/sh

          for file in *.svg
          do
          /usr/bin/inkscape -z -f "${file}" -w 640 -e "${file}.png"
          done


          the example above converts all .svg files in the current directory, adding .png extension to the output files.






          share|improve this answer


























          • I'm trying to export several hundreds of svgs, how can I set the export value (dest) so they keep their name? because this seems to work fine for a small quantity.

            – Uri Herrera
            Oct 30 '12 at 4:33











          • @UriHerrera: I updated the answer

            – Sergey
            Oct 30 '12 at 4:46











          • all the files are saved {file}.svg.png format instead of {file}.png? how to fix that? and also on the original SVG it appears little shortcut icon on the bottom right which disappear when it's converted to PNG (I'm trying to convert icons pack)

            – Tosho
            Dec 15 '12 at 15:52











          • @Tosho Currently I'm on Windows, but it should be something like this: pastebin.com/TEDfvxPC

            – user31389
            Sep 23 '13 at 12:05






          • 2





            @Tosho You can also do ${file%svg}png. You can read here for more possibilities.

            – jja
            May 12 '15 at 15:22



















          5














          Graphical Nautilus Script





          Overview



          The command line is great for batch conversions but sometimes you just don't want to leave the comfort of your GUI. That's why I coded a GUI-based Nautilus script to batch convert SVG files to PNG images. Other file managers with custom actions (e.g. Thunar) should be supported, too.



          Screenshot



          enter image description here



          Script



          #!/bin/bash

          # NAME: SVG2PNG
          # VERSION: 0.1
          # AUTHOR: (c) 2014 Glutanimate (https://github.com/Glutanimate)
          #
          # DESCRIPTION: Simple application to convert SVG files to PNG files based on DPI or resolution.
          # Designed to work as a context menu script in file managers like Nautilus and Thunar.
          #
          # FEATURES: - Converts SVG image file to PNG raster of a specific DPI or width
          # - SVG preview
          # - choose between converting the full SVG page or only the cropped image
          #
          # DEPENDENCIES: inkscape imagemagick yad
          # YAD (1) is an advanced for of Zenity with many improvements. It's not included in the
          # official Ubuntu repos yet (2) but can be installed from a webupd8 PPA (3)
          #
          # LICENSE: MIT license (http://opensource.org/licenses/MIT)
          #
          # NOTICE: THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
          # INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
          # PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
          # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
          # TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE
          # OR OTHER DEALINGS IN THE SOFTWARE.
          #
          #
          # USAGE: SVG2PNG image1.svg image2.svg [..]
          # I recommend installing this script as a context menu action for your file manager.
          # Instructions for Nautilus may be found on AskUbuntu (4).
          #
          # NOTES: The script uses convert for previews because it's faster. For optimal results
          # the actual conversion is done with inkscape's command line interface.
          #
          # LINKS: (1) https://code.google.com/p/yad/
          # (2) https://bugs.launchpad.net/ubuntu/+bug/796633
          # (3) https://launchpad.net/~webupd8team/+archive/y-ppa-manager
          # (4) https://askubuntu.com/questions/236414/how-can-i-install-a-nautilus-script

          ############## DIALOGS ###################

          TITLE="SVG to PNG"
          ICON="svg"

          ############## USGCHECKS #################

          # checks if user selected an item

          if [ $# -eq 0 ]
          then
          yad --title="$TITLE"
          --image=dialog-error
          --window-icon=dialog-error
          --class="$WMCLASS"
          --text="Error: no file selected"
          --button="Ok":0
          echo "Error: no file selected"
          exit
          fi

          ############### GLOBVAR ##################

          SVGFILES="$@"
          TEMPDIR=$(mktemp -d)
          PREVIEWIMG="$TEMPDIR/svgpreview.png"

          ############### CLEANUP ##################

          trap "rm -r $TEMPDIR" EXIT

          ############## FUNCTIONS #################

          converttosvg_dpi(){

          echo "Converting based on DPI."

          while [ $# -gt 0 ]; do

          echo "$# file(s) left to convert."
          SVGFILE="$1"
          FILESTEM="${SVGFILE%%.*}"
          PNGFILE="$FILESTEM".png
          inkscape "$SVGFILE" -z --export-dpi="$DPI"
          --"$AREASETTING" --export-png="$PNGFILE"
          shift

          done
          echo "Done."

          }

          converttosvg_res(){

          echo "Converting based on Width."

          while [ $# -gt 0 ]; do

          echo "$# file(s) left to convert."
          SVGFILE="$1"
          FILESTEM="${SVGFILE%%.*}"
          PNGFILE="$FILESTEM".png
          inkscape "$SVGFILE" -z --export-width="$WIDTH"
          --"$AREASETTING" --export-png="$PNGFILE"
          shift

          done
          echo "Done."

          }

          createpreview() {
          convert -resize 128x "$1" "$PREVIEWIMG"
          }

          getsettings() {

          SETTINGS=$(yad --window-icon "$ICON" --image "$PREVIEWIMG" --width 300 --height 200 --always-print-result
          --form --separator="|" --title="$TITLE" --text "Please choose the DPI or resolution to convert to."
          --field="DPI:NUM" 10[!80..600[!10]] --field="Width in px:NUM" 16[!16..4096[!16]]
          --field="Area:":CB "Drawing"!"Page"
          --button="Convert based on DPI:2" --button="Convert based on Resolution:3" --button="gtk-cancel:1")

          RET=$? # Exit code?

          if [ "$RET" = 252 ] || [ "$RET" = 1 ] # WM-Close or "Abort"
          then
          echo "Exiting..."
          exit
          fi

          DPI=$(printf %.0f $(cut -d "|" -f 1 <<<"$SETTINGS")) #round values
          WIDTH=$(printf %.0f $(cut -d "|" -f 2 <<<"$SETTINGS"))
          AREA=$(cut -d "|" -f 3 <<<"$SETTINGS")

          case "$AREA" in

          Drawing)
          AREASETTING="export-area-drawing"
          ;;

          Page)
          AREASETTING="export-area-page"
          ;;

          esac

          echo "DPI set to $DPI"
          echo "Width set to $WIDTH"
          echo "Area set to $AREA"

          }


          ################ MAIN ####################

          createpreview "$1"
          getsettings

          case "$RET" in

          2)
          echo 2
          converttosvg_dpi "$@"
          ;;

          3)
          echo 3
          converttosvg_res "$@"
          ;;

          esac

          exit 0


          I will try to keep this answer updated but please check out my Github repository for the latest version of the script.



          Installation



          Generic installation instructions for all Nautilus scripts may be found here. The following commands should cover all the necessary dependencies:



          sudo add-apt-repository ppa:webupd8team/y-ppa-manager
          sudo apt-get update
          sudo apt-get install yad inkscape imagemagick


          For further information please consult the script header above.



          Usage



          After installing the script you should be able to invoke it from your file manager's context menu. Simply select one or more SVG files and click on the appropriate entry in your context menu. A GUI dialog should come up with several options concering the conversion.



          You can either convert the SVG based on DPI or width. The aspect ratio will be conserved in both cases. Make sure to supply your DPI or width of choice before clicking on the conversion buttons.



          You can also choose between exporting the full SVG file or only the cropped drawing. If your SVG canvas has a lot of empty space it's advisable to choose "Drawing" as the export option.






          share|improve this answer

































            2














            Here's a slightly different alternative solution in a more readable scripting language - python. It can batch export all your svgs. Particularly ideal if you're doing Android dev and have to make multiple pngs from a single svg.



            Disclaimer: I wrote the lib. Hope it helps someone.



            Click here.



            For a simple use, download the library into a folder, put the svgs in the same folder, then run



            python exporter.py


            in the command line/terminal after you cd to the folder. For more advanced options, do check out the README.






            share|improve this answer


























            • Thanks David, I have edited my answer to provide more details!

              – Kevin Lee
              Mar 28 '16 at 14:16



















            1














            If not all files, but only certain SVG files need to be converted to PNG, one might use sed to automatically generate the file names:



            inkscape --without-gui --export-width=1280 --export-png=`echo $1 |sed -e 's/svg$/png/'` $1





            share|improve this answer























              Your Answer








              StackExchange.ready(function() {
              var channelOptions = {
              tags: "".split(" "),
              id: "89"
              };
              initTagRenderer("".split(" "), "".split(" "), channelOptions);

              StackExchange.using("externalEditor", function() {
              // Have to fire editor after snippets, if snippets enabled
              if (StackExchange.settings.snippets.snippetsEnabled) {
              StackExchange.using("snippets", function() {
              createEditor();
              });
              }
              else {
              createEditor();
              }
              });

              function createEditor() {
              StackExchange.prepareEditor({
              heartbeatType: 'answer',
              autoActivateHeartbeat: false,
              convertImagesToLinks: true,
              noModals: true,
              showLowRepImageUploadWarning: true,
              reputationToPostImages: 10,
              bindNavPrevention: true,
              postfix: "",
              imageUploader: {
              brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
              contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
              allowUrls: true
              },
              onDemand: true,
              discardSelector: ".discard-answer"
              ,immediatelyShowMarkdownHelp:true
              });


              }
              });














              draft saved

              draft discarded


















              StackExchange.ready(
              function () {
              StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f209449%2fis-there-a-way-to-batch-export-svgs-to-pngs%23new-answer', 'question_page');
              }
              );

              Post as a guest















              Required, but never shown

























              5 Answers
              5






              active

              oldest

              votes








              5 Answers
              5






              active

              oldest

              votes









              active

              oldest

              votes






              active

              oldest

              votes









              16














              Inspired by the previously accepted answer I came up with this one-liner:



              for file in *.svg; do inkscape $file -e ${file%svg}png; done


              This way you don't need to call a script. If you wanted to, you could create an alias for converting all svgs in the current directory to pngs:



              alias svgtopng='for file in *.svg; do inkscape $file -e ${file%svg}png; done'





              share|improve this answer





















              • 1





                ${file%svg}png is a great trick! I had not seen that before.

                – Chester
                Jan 19 '17 at 20:49
















              16














              Inspired by the previously accepted answer I came up with this one-liner:



              for file in *.svg; do inkscape $file -e ${file%svg}png; done


              This way you don't need to call a script. If you wanted to, you could create an alias for converting all svgs in the current directory to pngs:



              alias svgtopng='for file in *.svg; do inkscape $file -e ${file%svg}png; done'





              share|improve this answer





















              • 1





                ${file%svg}png is a great trick! I had not seen that before.

                – Chester
                Jan 19 '17 at 20:49














              16












              16








              16







              Inspired by the previously accepted answer I came up with this one-liner:



              for file in *.svg; do inkscape $file -e ${file%svg}png; done


              This way you don't need to call a script. If you wanted to, you could create an alias for converting all svgs in the current directory to pngs:



              alias svgtopng='for file in *.svg; do inkscape $file -e ${file%svg}png; done'





              share|improve this answer















              Inspired by the previously accepted answer I came up with this one-liner:



              for file in *.svg; do inkscape $file -e ${file%svg}png; done


              This way you don't need to call a script. If you wanted to, you could create an alias for converting all svgs in the current directory to pngs:



              alias svgtopng='for file in *.svg; do inkscape $file -e ${file%svg}png; done'






              share|improve this answer














              share|improve this answer



              share|improve this answer








              edited Feb 18 at 13:32

























              answered Dec 15 '15 at 10:16









              Matthias BrandtMatthias Brandt

              18617




              18617








              • 1





                ${file%svg}png is a great trick! I had not seen that before.

                – Chester
                Jan 19 '17 at 20:49














              • 1





                ${file%svg}png is a great trick! I had not seen that before.

                – Chester
                Jan 19 '17 at 20:49








              1




              1





              ${file%svg}png is a great trick! I had not seen that before.

              – Chester
              Jan 19 '17 at 20:49





              ${file%svg}png is a great trick! I had not seen that before.

              – Chester
              Jan 19 '17 at 20:49













              24














              It appears you can use Inkscape from command line:



              `#{INKSCAPE_PATH} -z -f #{source_svg} -w #{width} -j -e #{dest_png}`


              more details



              I imagine you can write a simple bash script to process all SVG files:



              #!/bin/sh

              for file in *.svg
              do
              /usr/bin/inkscape -z -f "${file}" -w 640 -e "${file}.png"
              done


              the example above converts all .svg files in the current directory, adding .png extension to the output files.






              share|improve this answer


























              • I'm trying to export several hundreds of svgs, how can I set the export value (dest) so they keep their name? because this seems to work fine for a small quantity.

                – Uri Herrera
                Oct 30 '12 at 4:33











              • @UriHerrera: I updated the answer

                – Sergey
                Oct 30 '12 at 4:46











              • all the files are saved {file}.svg.png format instead of {file}.png? how to fix that? and also on the original SVG it appears little shortcut icon on the bottom right which disappear when it's converted to PNG (I'm trying to convert icons pack)

                – Tosho
                Dec 15 '12 at 15:52











              • @Tosho Currently I'm on Windows, but it should be something like this: pastebin.com/TEDfvxPC

                – user31389
                Sep 23 '13 at 12:05






              • 2





                @Tosho You can also do ${file%svg}png. You can read here for more possibilities.

                – jja
                May 12 '15 at 15:22
















              24














              It appears you can use Inkscape from command line:



              `#{INKSCAPE_PATH} -z -f #{source_svg} -w #{width} -j -e #{dest_png}`


              more details



              I imagine you can write a simple bash script to process all SVG files:



              #!/bin/sh

              for file in *.svg
              do
              /usr/bin/inkscape -z -f "${file}" -w 640 -e "${file}.png"
              done


              the example above converts all .svg files in the current directory, adding .png extension to the output files.






              share|improve this answer


























              • I'm trying to export several hundreds of svgs, how can I set the export value (dest) so they keep their name? because this seems to work fine for a small quantity.

                – Uri Herrera
                Oct 30 '12 at 4:33











              • @UriHerrera: I updated the answer

                – Sergey
                Oct 30 '12 at 4:46











              • all the files are saved {file}.svg.png format instead of {file}.png? how to fix that? and also on the original SVG it appears little shortcut icon on the bottom right which disappear when it's converted to PNG (I'm trying to convert icons pack)

                – Tosho
                Dec 15 '12 at 15:52











              • @Tosho Currently I'm on Windows, but it should be something like this: pastebin.com/TEDfvxPC

                – user31389
                Sep 23 '13 at 12:05






              • 2





                @Tosho You can also do ${file%svg}png. You can read here for more possibilities.

                – jja
                May 12 '15 at 15:22














              24












              24








              24







              It appears you can use Inkscape from command line:



              `#{INKSCAPE_PATH} -z -f #{source_svg} -w #{width} -j -e #{dest_png}`


              more details



              I imagine you can write a simple bash script to process all SVG files:



              #!/bin/sh

              for file in *.svg
              do
              /usr/bin/inkscape -z -f "${file}" -w 640 -e "${file}.png"
              done


              the example above converts all .svg files in the current directory, adding .png extension to the output files.






              share|improve this answer















              It appears you can use Inkscape from command line:



              `#{INKSCAPE_PATH} -z -f #{source_svg} -w #{width} -j -e #{dest_png}`


              more details



              I imagine you can write a simple bash script to process all SVG files:



              #!/bin/sh

              for file in *.svg
              do
              /usr/bin/inkscape -z -f "${file}" -w 640 -e "${file}.png"
              done


              the example above converts all .svg files in the current directory, adding .png extension to the output files.







              share|improve this answer














              share|improve this answer



              share|improve this answer








              edited May 23 '17 at 12:39









              Community

              1




              1










              answered Oct 30 '12 at 4:10









              SergeySergey

              36.6k98799




              36.6k98799













              • I'm trying to export several hundreds of svgs, how can I set the export value (dest) so they keep their name? because this seems to work fine for a small quantity.

                – Uri Herrera
                Oct 30 '12 at 4:33











              • @UriHerrera: I updated the answer

                – Sergey
                Oct 30 '12 at 4:46











              • all the files are saved {file}.svg.png format instead of {file}.png? how to fix that? and also on the original SVG it appears little shortcut icon on the bottom right which disappear when it's converted to PNG (I'm trying to convert icons pack)

                – Tosho
                Dec 15 '12 at 15:52











              • @Tosho Currently I'm on Windows, but it should be something like this: pastebin.com/TEDfvxPC

                – user31389
                Sep 23 '13 at 12:05






              • 2





                @Tosho You can also do ${file%svg}png. You can read here for more possibilities.

                – jja
                May 12 '15 at 15:22



















              • I'm trying to export several hundreds of svgs, how can I set the export value (dest) so they keep their name? because this seems to work fine for a small quantity.

                – Uri Herrera
                Oct 30 '12 at 4:33











              • @UriHerrera: I updated the answer

                – Sergey
                Oct 30 '12 at 4:46











              • all the files are saved {file}.svg.png format instead of {file}.png? how to fix that? and also on the original SVG it appears little shortcut icon on the bottom right which disappear when it's converted to PNG (I'm trying to convert icons pack)

                – Tosho
                Dec 15 '12 at 15:52











              • @Tosho Currently I'm on Windows, but it should be something like this: pastebin.com/TEDfvxPC

                – user31389
                Sep 23 '13 at 12:05






              • 2





                @Tosho You can also do ${file%svg}png. You can read here for more possibilities.

                – jja
                May 12 '15 at 15:22

















              I'm trying to export several hundreds of svgs, how can I set the export value (dest) so they keep their name? because this seems to work fine for a small quantity.

              – Uri Herrera
              Oct 30 '12 at 4:33





              I'm trying to export several hundreds of svgs, how can I set the export value (dest) so they keep their name? because this seems to work fine for a small quantity.

              – Uri Herrera
              Oct 30 '12 at 4:33













              @UriHerrera: I updated the answer

              – Sergey
              Oct 30 '12 at 4:46





              @UriHerrera: I updated the answer

              – Sergey
              Oct 30 '12 at 4:46













              all the files are saved {file}.svg.png format instead of {file}.png? how to fix that? and also on the original SVG it appears little shortcut icon on the bottom right which disappear when it's converted to PNG (I'm trying to convert icons pack)

              – Tosho
              Dec 15 '12 at 15:52





              all the files are saved {file}.svg.png format instead of {file}.png? how to fix that? and also on the original SVG it appears little shortcut icon on the bottom right which disappear when it's converted to PNG (I'm trying to convert icons pack)

              – Tosho
              Dec 15 '12 at 15:52













              @Tosho Currently I'm on Windows, but it should be something like this: pastebin.com/TEDfvxPC

              – user31389
              Sep 23 '13 at 12:05





              @Tosho Currently I'm on Windows, but it should be something like this: pastebin.com/TEDfvxPC

              – user31389
              Sep 23 '13 at 12:05




              2




              2





              @Tosho You can also do ${file%svg}png. You can read here for more possibilities.

              – jja
              May 12 '15 at 15:22





              @Tosho You can also do ${file%svg}png. You can read here for more possibilities.

              – jja
              May 12 '15 at 15:22











              5














              Graphical Nautilus Script





              Overview



              The command line is great for batch conversions but sometimes you just don't want to leave the comfort of your GUI. That's why I coded a GUI-based Nautilus script to batch convert SVG files to PNG images. Other file managers with custom actions (e.g. Thunar) should be supported, too.



              Screenshot



              enter image description here



              Script



              #!/bin/bash

              # NAME: SVG2PNG
              # VERSION: 0.1
              # AUTHOR: (c) 2014 Glutanimate (https://github.com/Glutanimate)
              #
              # DESCRIPTION: Simple application to convert SVG files to PNG files based on DPI or resolution.
              # Designed to work as a context menu script in file managers like Nautilus and Thunar.
              #
              # FEATURES: - Converts SVG image file to PNG raster of a specific DPI or width
              # - SVG preview
              # - choose between converting the full SVG page or only the cropped image
              #
              # DEPENDENCIES: inkscape imagemagick yad
              # YAD (1) is an advanced for of Zenity with many improvements. It's not included in the
              # official Ubuntu repos yet (2) but can be installed from a webupd8 PPA (3)
              #
              # LICENSE: MIT license (http://opensource.org/licenses/MIT)
              #
              # NOTICE: THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
              # INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
              # PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
              # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
              # TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE
              # OR OTHER DEALINGS IN THE SOFTWARE.
              #
              #
              # USAGE: SVG2PNG image1.svg image2.svg [..]
              # I recommend installing this script as a context menu action for your file manager.
              # Instructions for Nautilus may be found on AskUbuntu (4).
              #
              # NOTES: The script uses convert for previews because it's faster. For optimal results
              # the actual conversion is done with inkscape's command line interface.
              #
              # LINKS: (1) https://code.google.com/p/yad/
              # (2) https://bugs.launchpad.net/ubuntu/+bug/796633
              # (3) https://launchpad.net/~webupd8team/+archive/y-ppa-manager
              # (4) https://askubuntu.com/questions/236414/how-can-i-install-a-nautilus-script

              ############## DIALOGS ###################

              TITLE="SVG to PNG"
              ICON="svg"

              ############## USGCHECKS #################

              # checks if user selected an item

              if [ $# -eq 0 ]
              then
              yad --title="$TITLE"
              --image=dialog-error
              --window-icon=dialog-error
              --class="$WMCLASS"
              --text="Error: no file selected"
              --button="Ok":0
              echo "Error: no file selected"
              exit
              fi

              ############### GLOBVAR ##################

              SVGFILES="$@"
              TEMPDIR=$(mktemp -d)
              PREVIEWIMG="$TEMPDIR/svgpreview.png"

              ############### CLEANUP ##################

              trap "rm -r $TEMPDIR" EXIT

              ############## FUNCTIONS #################

              converttosvg_dpi(){

              echo "Converting based on DPI."

              while [ $# -gt 0 ]; do

              echo "$# file(s) left to convert."
              SVGFILE="$1"
              FILESTEM="${SVGFILE%%.*}"
              PNGFILE="$FILESTEM".png
              inkscape "$SVGFILE" -z --export-dpi="$DPI"
              --"$AREASETTING" --export-png="$PNGFILE"
              shift

              done
              echo "Done."

              }

              converttosvg_res(){

              echo "Converting based on Width."

              while [ $# -gt 0 ]; do

              echo "$# file(s) left to convert."
              SVGFILE="$1"
              FILESTEM="${SVGFILE%%.*}"
              PNGFILE="$FILESTEM".png
              inkscape "$SVGFILE" -z --export-width="$WIDTH"
              --"$AREASETTING" --export-png="$PNGFILE"
              shift

              done
              echo "Done."

              }

              createpreview() {
              convert -resize 128x "$1" "$PREVIEWIMG"
              }

              getsettings() {

              SETTINGS=$(yad --window-icon "$ICON" --image "$PREVIEWIMG" --width 300 --height 200 --always-print-result
              --form --separator="|" --title="$TITLE" --text "Please choose the DPI or resolution to convert to."
              --field="DPI:NUM" 10[!80..600[!10]] --field="Width in px:NUM" 16[!16..4096[!16]]
              --field="Area:":CB "Drawing"!"Page"
              --button="Convert based on DPI:2" --button="Convert based on Resolution:3" --button="gtk-cancel:1")

              RET=$? # Exit code?

              if [ "$RET" = 252 ] || [ "$RET" = 1 ] # WM-Close or "Abort"
              then
              echo "Exiting..."
              exit
              fi

              DPI=$(printf %.0f $(cut -d "|" -f 1 <<<"$SETTINGS")) #round values
              WIDTH=$(printf %.0f $(cut -d "|" -f 2 <<<"$SETTINGS"))
              AREA=$(cut -d "|" -f 3 <<<"$SETTINGS")

              case "$AREA" in

              Drawing)
              AREASETTING="export-area-drawing"
              ;;

              Page)
              AREASETTING="export-area-page"
              ;;

              esac

              echo "DPI set to $DPI"
              echo "Width set to $WIDTH"
              echo "Area set to $AREA"

              }


              ################ MAIN ####################

              createpreview "$1"
              getsettings

              case "$RET" in

              2)
              echo 2
              converttosvg_dpi "$@"
              ;;

              3)
              echo 3
              converttosvg_res "$@"
              ;;

              esac

              exit 0


              I will try to keep this answer updated but please check out my Github repository for the latest version of the script.



              Installation



              Generic installation instructions for all Nautilus scripts may be found here. The following commands should cover all the necessary dependencies:



              sudo add-apt-repository ppa:webupd8team/y-ppa-manager
              sudo apt-get update
              sudo apt-get install yad inkscape imagemagick


              For further information please consult the script header above.



              Usage



              After installing the script you should be able to invoke it from your file manager's context menu. Simply select one or more SVG files and click on the appropriate entry in your context menu. A GUI dialog should come up with several options concering the conversion.



              You can either convert the SVG based on DPI or width. The aspect ratio will be conserved in both cases. Make sure to supply your DPI or width of choice before clicking on the conversion buttons.



              You can also choose between exporting the full SVG file or only the cropped drawing. If your SVG canvas has a lot of empty space it's advisable to choose "Drawing" as the export option.






              share|improve this answer






























                5














                Graphical Nautilus Script





                Overview



                The command line is great for batch conversions but sometimes you just don't want to leave the comfort of your GUI. That's why I coded a GUI-based Nautilus script to batch convert SVG files to PNG images. Other file managers with custom actions (e.g. Thunar) should be supported, too.



                Screenshot



                enter image description here



                Script



                #!/bin/bash

                # NAME: SVG2PNG
                # VERSION: 0.1
                # AUTHOR: (c) 2014 Glutanimate (https://github.com/Glutanimate)
                #
                # DESCRIPTION: Simple application to convert SVG files to PNG files based on DPI or resolution.
                # Designed to work as a context menu script in file managers like Nautilus and Thunar.
                #
                # FEATURES: - Converts SVG image file to PNG raster of a specific DPI or width
                # - SVG preview
                # - choose between converting the full SVG page or only the cropped image
                #
                # DEPENDENCIES: inkscape imagemagick yad
                # YAD (1) is an advanced for of Zenity with many improvements. It's not included in the
                # official Ubuntu repos yet (2) but can be installed from a webupd8 PPA (3)
                #
                # LICENSE: MIT license (http://opensource.org/licenses/MIT)
                #
                # NOTICE: THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
                # INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
                # PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
                # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
                # TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE
                # OR OTHER DEALINGS IN THE SOFTWARE.
                #
                #
                # USAGE: SVG2PNG image1.svg image2.svg [..]
                # I recommend installing this script as a context menu action for your file manager.
                # Instructions for Nautilus may be found on AskUbuntu (4).
                #
                # NOTES: The script uses convert for previews because it's faster. For optimal results
                # the actual conversion is done with inkscape's command line interface.
                #
                # LINKS: (1) https://code.google.com/p/yad/
                # (2) https://bugs.launchpad.net/ubuntu/+bug/796633
                # (3) https://launchpad.net/~webupd8team/+archive/y-ppa-manager
                # (4) https://askubuntu.com/questions/236414/how-can-i-install-a-nautilus-script

                ############## DIALOGS ###################

                TITLE="SVG to PNG"
                ICON="svg"

                ############## USGCHECKS #################

                # checks if user selected an item

                if [ $# -eq 0 ]
                then
                yad --title="$TITLE"
                --image=dialog-error
                --window-icon=dialog-error
                --class="$WMCLASS"
                --text="Error: no file selected"
                --button="Ok":0
                echo "Error: no file selected"
                exit
                fi

                ############### GLOBVAR ##################

                SVGFILES="$@"
                TEMPDIR=$(mktemp -d)
                PREVIEWIMG="$TEMPDIR/svgpreview.png"

                ############### CLEANUP ##################

                trap "rm -r $TEMPDIR" EXIT

                ############## FUNCTIONS #################

                converttosvg_dpi(){

                echo "Converting based on DPI."

                while [ $# -gt 0 ]; do

                echo "$# file(s) left to convert."
                SVGFILE="$1"
                FILESTEM="${SVGFILE%%.*}"
                PNGFILE="$FILESTEM".png
                inkscape "$SVGFILE" -z --export-dpi="$DPI"
                --"$AREASETTING" --export-png="$PNGFILE"
                shift

                done
                echo "Done."

                }

                converttosvg_res(){

                echo "Converting based on Width."

                while [ $# -gt 0 ]; do

                echo "$# file(s) left to convert."
                SVGFILE="$1"
                FILESTEM="${SVGFILE%%.*}"
                PNGFILE="$FILESTEM".png
                inkscape "$SVGFILE" -z --export-width="$WIDTH"
                --"$AREASETTING" --export-png="$PNGFILE"
                shift

                done
                echo "Done."

                }

                createpreview() {
                convert -resize 128x "$1" "$PREVIEWIMG"
                }

                getsettings() {

                SETTINGS=$(yad --window-icon "$ICON" --image "$PREVIEWIMG" --width 300 --height 200 --always-print-result
                --form --separator="|" --title="$TITLE" --text "Please choose the DPI or resolution to convert to."
                --field="DPI:NUM" 10[!80..600[!10]] --field="Width in px:NUM" 16[!16..4096[!16]]
                --field="Area:":CB "Drawing"!"Page"
                --button="Convert based on DPI:2" --button="Convert based on Resolution:3" --button="gtk-cancel:1")

                RET=$? # Exit code?

                if [ "$RET" = 252 ] || [ "$RET" = 1 ] # WM-Close or "Abort"
                then
                echo "Exiting..."
                exit
                fi

                DPI=$(printf %.0f $(cut -d "|" -f 1 <<<"$SETTINGS")) #round values
                WIDTH=$(printf %.0f $(cut -d "|" -f 2 <<<"$SETTINGS"))
                AREA=$(cut -d "|" -f 3 <<<"$SETTINGS")

                case "$AREA" in

                Drawing)
                AREASETTING="export-area-drawing"
                ;;

                Page)
                AREASETTING="export-area-page"
                ;;

                esac

                echo "DPI set to $DPI"
                echo "Width set to $WIDTH"
                echo "Area set to $AREA"

                }


                ################ MAIN ####################

                createpreview "$1"
                getsettings

                case "$RET" in

                2)
                echo 2
                converttosvg_dpi "$@"
                ;;

                3)
                echo 3
                converttosvg_res "$@"
                ;;

                esac

                exit 0


                I will try to keep this answer updated but please check out my Github repository for the latest version of the script.



                Installation



                Generic installation instructions for all Nautilus scripts may be found here. The following commands should cover all the necessary dependencies:



                sudo add-apt-repository ppa:webupd8team/y-ppa-manager
                sudo apt-get update
                sudo apt-get install yad inkscape imagemagick


                For further information please consult the script header above.



                Usage



                After installing the script you should be able to invoke it from your file manager's context menu. Simply select one or more SVG files and click on the appropriate entry in your context menu. A GUI dialog should come up with several options concering the conversion.



                You can either convert the SVG based on DPI or width. The aspect ratio will be conserved in both cases. Make sure to supply your DPI or width of choice before clicking on the conversion buttons.



                You can also choose between exporting the full SVG file or only the cropped drawing. If your SVG canvas has a lot of empty space it's advisable to choose "Drawing" as the export option.






                share|improve this answer




























                  5












                  5








                  5







                  Graphical Nautilus Script





                  Overview



                  The command line is great for batch conversions but sometimes you just don't want to leave the comfort of your GUI. That's why I coded a GUI-based Nautilus script to batch convert SVG files to PNG images. Other file managers with custom actions (e.g. Thunar) should be supported, too.



                  Screenshot



                  enter image description here



                  Script



                  #!/bin/bash

                  # NAME: SVG2PNG
                  # VERSION: 0.1
                  # AUTHOR: (c) 2014 Glutanimate (https://github.com/Glutanimate)
                  #
                  # DESCRIPTION: Simple application to convert SVG files to PNG files based on DPI or resolution.
                  # Designed to work as a context menu script in file managers like Nautilus and Thunar.
                  #
                  # FEATURES: - Converts SVG image file to PNG raster of a specific DPI or width
                  # - SVG preview
                  # - choose between converting the full SVG page or only the cropped image
                  #
                  # DEPENDENCIES: inkscape imagemagick yad
                  # YAD (1) is an advanced for of Zenity with many improvements. It's not included in the
                  # official Ubuntu repos yet (2) but can be installed from a webupd8 PPA (3)
                  #
                  # LICENSE: MIT license (http://opensource.org/licenses/MIT)
                  #
                  # NOTICE: THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
                  # INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
                  # PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
                  # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
                  # TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE
                  # OR OTHER DEALINGS IN THE SOFTWARE.
                  #
                  #
                  # USAGE: SVG2PNG image1.svg image2.svg [..]
                  # I recommend installing this script as a context menu action for your file manager.
                  # Instructions for Nautilus may be found on AskUbuntu (4).
                  #
                  # NOTES: The script uses convert for previews because it's faster. For optimal results
                  # the actual conversion is done with inkscape's command line interface.
                  #
                  # LINKS: (1) https://code.google.com/p/yad/
                  # (2) https://bugs.launchpad.net/ubuntu/+bug/796633
                  # (3) https://launchpad.net/~webupd8team/+archive/y-ppa-manager
                  # (4) https://askubuntu.com/questions/236414/how-can-i-install-a-nautilus-script

                  ############## DIALOGS ###################

                  TITLE="SVG to PNG"
                  ICON="svg"

                  ############## USGCHECKS #################

                  # checks if user selected an item

                  if [ $# -eq 0 ]
                  then
                  yad --title="$TITLE"
                  --image=dialog-error
                  --window-icon=dialog-error
                  --class="$WMCLASS"
                  --text="Error: no file selected"
                  --button="Ok":0
                  echo "Error: no file selected"
                  exit
                  fi

                  ############### GLOBVAR ##################

                  SVGFILES="$@"
                  TEMPDIR=$(mktemp -d)
                  PREVIEWIMG="$TEMPDIR/svgpreview.png"

                  ############### CLEANUP ##################

                  trap "rm -r $TEMPDIR" EXIT

                  ############## FUNCTIONS #################

                  converttosvg_dpi(){

                  echo "Converting based on DPI."

                  while [ $# -gt 0 ]; do

                  echo "$# file(s) left to convert."
                  SVGFILE="$1"
                  FILESTEM="${SVGFILE%%.*}"
                  PNGFILE="$FILESTEM".png
                  inkscape "$SVGFILE" -z --export-dpi="$DPI"
                  --"$AREASETTING" --export-png="$PNGFILE"
                  shift

                  done
                  echo "Done."

                  }

                  converttosvg_res(){

                  echo "Converting based on Width."

                  while [ $# -gt 0 ]; do

                  echo "$# file(s) left to convert."
                  SVGFILE="$1"
                  FILESTEM="${SVGFILE%%.*}"
                  PNGFILE="$FILESTEM".png
                  inkscape "$SVGFILE" -z --export-width="$WIDTH"
                  --"$AREASETTING" --export-png="$PNGFILE"
                  shift

                  done
                  echo "Done."

                  }

                  createpreview() {
                  convert -resize 128x "$1" "$PREVIEWIMG"
                  }

                  getsettings() {

                  SETTINGS=$(yad --window-icon "$ICON" --image "$PREVIEWIMG" --width 300 --height 200 --always-print-result
                  --form --separator="|" --title="$TITLE" --text "Please choose the DPI or resolution to convert to."
                  --field="DPI:NUM" 10[!80..600[!10]] --field="Width in px:NUM" 16[!16..4096[!16]]
                  --field="Area:":CB "Drawing"!"Page"
                  --button="Convert based on DPI:2" --button="Convert based on Resolution:3" --button="gtk-cancel:1")

                  RET=$? # Exit code?

                  if [ "$RET" = 252 ] || [ "$RET" = 1 ] # WM-Close or "Abort"
                  then
                  echo "Exiting..."
                  exit
                  fi

                  DPI=$(printf %.0f $(cut -d "|" -f 1 <<<"$SETTINGS")) #round values
                  WIDTH=$(printf %.0f $(cut -d "|" -f 2 <<<"$SETTINGS"))
                  AREA=$(cut -d "|" -f 3 <<<"$SETTINGS")

                  case "$AREA" in

                  Drawing)
                  AREASETTING="export-area-drawing"
                  ;;

                  Page)
                  AREASETTING="export-area-page"
                  ;;

                  esac

                  echo "DPI set to $DPI"
                  echo "Width set to $WIDTH"
                  echo "Area set to $AREA"

                  }


                  ################ MAIN ####################

                  createpreview "$1"
                  getsettings

                  case "$RET" in

                  2)
                  echo 2
                  converttosvg_dpi "$@"
                  ;;

                  3)
                  echo 3
                  converttosvg_res "$@"
                  ;;

                  esac

                  exit 0


                  I will try to keep this answer updated but please check out my Github repository for the latest version of the script.



                  Installation



                  Generic installation instructions for all Nautilus scripts may be found here. The following commands should cover all the necessary dependencies:



                  sudo add-apt-repository ppa:webupd8team/y-ppa-manager
                  sudo apt-get update
                  sudo apt-get install yad inkscape imagemagick


                  For further information please consult the script header above.



                  Usage



                  After installing the script you should be able to invoke it from your file manager's context menu. Simply select one or more SVG files and click on the appropriate entry in your context menu. A GUI dialog should come up with several options concering the conversion.



                  You can either convert the SVG based on DPI or width. The aspect ratio will be conserved in both cases. Make sure to supply your DPI or width of choice before clicking on the conversion buttons.



                  You can also choose between exporting the full SVG file or only the cropped drawing. If your SVG canvas has a lot of empty space it's advisable to choose "Drawing" as the export option.






                  share|improve this answer















                  Graphical Nautilus Script





                  Overview



                  The command line is great for batch conversions but sometimes you just don't want to leave the comfort of your GUI. That's why I coded a GUI-based Nautilus script to batch convert SVG files to PNG images. Other file managers with custom actions (e.g. Thunar) should be supported, too.



                  Screenshot



                  enter image description here



                  Script



                  #!/bin/bash

                  # NAME: SVG2PNG
                  # VERSION: 0.1
                  # AUTHOR: (c) 2014 Glutanimate (https://github.com/Glutanimate)
                  #
                  # DESCRIPTION: Simple application to convert SVG files to PNG files based on DPI or resolution.
                  # Designed to work as a context menu script in file managers like Nautilus and Thunar.
                  #
                  # FEATURES: - Converts SVG image file to PNG raster of a specific DPI or width
                  # - SVG preview
                  # - choose between converting the full SVG page or only the cropped image
                  #
                  # DEPENDENCIES: inkscape imagemagick yad
                  # YAD (1) is an advanced for of Zenity with many improvements. It's not included in the
                  # official Ubuntu repos yet (2) but can be installed from a webupd8 PPA (3)
                  #
                  # LICENSE: MIT license (http://opensource.org/licenses/MIT)
                  #
                  # NOTICE: THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
                  # INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
                  # PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
                  # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
                  # TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE
                  # OR OTHER DEALINGS IN THE SOFTWARE.
                  #
                  #
                  # USAGE: SVG2PNG image1.svg image2.svg [..]
                  # I recommend installing this script as a context menu action for your file manager.
                  # Instructions for Nautilus may be found on AskUbuntu (4).
                  #
                  # NOTES: The script uses convert for previews because it's faster. For optimal results
                  # the actual conversion is done with inkscape's command line interface.
                  #
                  # LINKS: (1) https://code.google.com/p/yad/
                  # (2) https://bugs.launchpad.net/ubuntu/+bug/796633
                  # (3) https://launchpad.net/~webupd8team/+archive/y-ppa-manager
                  # (4) https://askubuntu.com/questions/236414/how-can-i-install-a-nautilus-script

                  ############## DIALOGS ###################

                  TITLE="SVG to PNG"
                  ICON="svg"

                  ############## USGCHECKS #################

                  # checks if user selected an item

                  if [ $# -eq 0 ]
                  then
                  yad --title="$TITLE"
                  --image=dialog-error
                  --window-icon=dialog-error
                  --class="$WMCLASS"
                  --text="Error: no file selected"
                  --button="Ok":0
                  echo "Error: no file selected"
                  exit
                  fi

                  ############### GLOBVAR ##################

                  SVGFILES="$@"
                  TEMPDIR=$(mktemp -d)
                  PREVIEWIMG="$TEMPDIR/svgpreview.png"

                  ############### CLEANUP ##################

                  trap "rm -r $TEMPDIR" EXIT

                  ############## FUNCTIONS #################

                  converttosvg_dpi(){

                  echo "Converting based on DPI."

                  while [ $# -gt 0 ]; do

                  echo "$# file(s) left to convert."
                  SVGFILE="$1"
                  FILESTEM="${SVGFILE%%.*}"
                  PNGFILE="$FILESTEM".png
                  inkscape "$SVGFILE" -z --export-dpi="$DPI"
                  --"$AREASETTING" --export-png="$PNGFILE"
                  shift

                  done
                  echo "Done."

                  }

                  converttosvg_res(){

                  echo "Converting based on Width."

                  while [ $# -gt 0 ]; do

                  echo "$# file(s) left to convert."
                  SVGFILE="$1"
                  FILESTEM="${SVGFILE%%.*}"
                  PNGFILE="$FILESTEM".png
                  inkscape "$SVGFILE" -z --export-width="$WIDTH"
                  --"$AREASETTING" --export-png="$PNGFILE"
                  shift

                  done
                  echo "Done."

                  }

                  createpreview() {
                  convert -resize 128x "$1" "$PREVIEWIMG"
                  }

                  getsettings() {

                  SETTINGS=$(yad --window-icon "$ICON" --image "$PREVIEWIMG" --width 300 --height 200 --always-print-result
                  --form --separator="|" --title="$TITLE" --text "Please choose the DPI or resolution to convert to."
                  --field="DPI:NUM" 10[!80..600[!10]] --field="Width in px:NUM" 16[!16..4096[!16]]
                  --field="Area:":CB "Drawing"!"Page"
                  --button="Convert based on DPI:2" --button="Convert based on Resolution:3" --button="gtk-cancel:1")

                  RET=$? # Exit code?

                  if [ "$RET" = 252 ] || [ "$RET" = 1 ] # WM-Close or "Abort"
                  then
                  echo "Exiting..."
                  exit
                  fi

                  DPI=$(printf %.0f $(cut -d "|" -f 1 <<<"$SETTINGS")) #round values
                  WIDTH=$(printf %.0f $(cut -d "|" -f 2 <<<"$SETTINGS"))
                  AREA=$(cut -d "|" -f 3 <<<"$SETTINGS")

                  case "$AREA" in

                  Drawing)
                  AREASETTING="export-area-drawing"
                  ;;

                  Page)
                  AREASETTING="export-area-page"
                  ;;

                  esac

                  echo "DPI set to $DPI"
                  echo "Width set to $WIDTH"
                  echo "Area set to $AREA"

                  }


                  ################ MAIN ####################

                  createpreview "$1"
                  getsettings

                  case "$RET" in

                  2)
                  echo 2
                  converttosvg_dpi "$@"
                  ;;

                  3)
                  echo 3
                  converttosvg_res "$@"
                  ;;

                  esac

                  exit 0


                  I will try to keep this answer updated but please check out my Github repository for the latest version of the script.



                  Installation



                  Generic installation instructions for all Nautilus scripts may be found here. The following commands should cover all the necessary dependencies:



                  sudo add-apt-repository ppa:webupd8team/y-ppa-manager
                  sudo apt-get update
                  sudo apt-get install yad inkscape imagemagick


                  For further information please consult the script header above.



                  Usage



                  After installing the script you should be able to invoke it from your file manager's context menu. Simply select one or more SVG files and click on the appropriate entry in your context menu. A GUI dialog should come up with several options concering the conversion.



                  You can either convert the SVG based on DPI or width. The aspect ratio will be conserved in both cases. Make sure to supply your DPI or width of choice before clicking on the conversion buttons.



                  You can also choose between exporting the full SVG file or only the cropped drawing. If your SVG canvas has a lot of empty space it's advisable to choose "Drawing" as the export option.







                  share|improve this answer














                  share|improve this answer



                  share|improve this answer








                  edited Apr 13 '17 at 12:24









                  Community

                  1




                  1










                  answered Jan 29 '14 at 13:47









                  GlutanimateGlutanimate

                  16.3k874132




                  16.3k874132























                      2














                      Here's a slightly different alternative solution in a more readable scripting language - python. It can batch export all your svgs. Particularly ideal if you're doing Android dev and have to make multiple pngs from a single svg.



                      Disclaimer: I wrote the lib. Hope it helps someone.



                      Click here.



                      For a simple use, download the library into a folder, put the svgs in the same folder, then run



                      python exporter.py


                      in the command line/terminal after you cd to the folder. For more advanced options, do check out the README.






                      share|improve this answer


























                      • Thanks David, I have edited my answer to provide more details!

                        – Kevin Lee
                        Mar 28 '16 at 14:16
















                      2














                      Here's a slightly different alternative solution in a more readable scripting language - python. It can batch export all your svgs. Particularly ideal if you're doing Android dev and have to make multiple pngs from a single svg.



                      Disclaimer: I wrote the lib. Hope it helps someone.



                      Click here.



                      For a simple use, download the library into a folder, put the svgs in the same folder, then run



                      python exporter.py


                      in the command line/terminal after you cd to the folder. For more advanced options, do check out the README.






                      share|improve this answer


























                      • Thanks David, I have edited my answer to provide more details!

                        – Kevin Lee
                        Mar 28 '16 at 14:16














                      2












                      2








                      2







                      Here's a slightly different alternative solution in a more readable scripting language - python. It can batch export all your svgs. Particularly ideal if you're doing Android dev and have to make multiple pngs from a single svg.



                      Disclaimer: I wrote the lib. Hope it helps someone.



                      Click here.



                      For a simple use, download the library into a folder, put the svgs in the same folder, then run



                      python exporter.py


                      in the command line/terminal after you cd to the folder. For more advanced options, do check out the README.






                      share|improve this answer















                      Here's a slightly different alternative solution in a more readable scripting language - python. It can batch export all your svgs. Particularly ideal if you're doing Android dev and have to make multiple pngs from a single svg.



                      Disclaimer: I wrote the lib. Hope it helps someone.



                      Click here.



                      For a simple use, download the library into a folder, put the svgs in the same folder, then run



                      python exporter.py


                      in the command line/terminal after you cd to the folder. For more advanced options, do check out the README.







                      share|improve this answer














                      share|improve this answer



                      share|improve this answer








                      edited Oct 24 '16 at 17:20

























                      answered Mar 28 '16 at 7:45









                      Kevin LeeKevin Lee

                      1214




                      1214













                      • Thanks David, I have edited my answer to provide more details!

                        – Kevin Lee
                        Mar 28 '16 at 14:16



















                      • Thanks David, I have edited my answer to provide more details!

                        – Kevin Lee
                        Mar 28 '16 at 14:16

















                      Thanks David, I have edited my answer to provide more details!

                      – Kevin Lee
                      Mar 28 '16 at 14:16





                      Thanks David, I have edited my answer to provide more details!

                      – Kevin Lee
                      Mar 28 '16 at 14:16











                      1














                      If not all files, but only certain SVG files need to be converted to PNG, one might use sed to automatically generate the file names:



                      inkscape --without-gui --export-width=1280 --export-png=`echo $1 |sed -e 's/svg$/png/'` $1





                      share|improve this answer




























                        1














                        If not all files, but only certain SVG files need to be converted to PNG, one might use sed to automatically generate the file names:



                        inkscape --without-gui --export-width=1280 --export-png=`echo $1 |sed -e 's/svg$/png/'` $1





                        share|improve this answer


























                          1












                          1








                          1







                          If not all files, but only certain SVG files need to be converted to PNG, one might use sed to automatically generate the file names:



                          inkscape --without-gui --export-width=1280 --export-png=`echo $1 |sed -e 's/svg$/png/'` $1





                          share|improve this answer













                          If not all files, but only certain SVG files need to be converted to PNG, one might use sed to automatically generate the file names:



                          inkscape --without-gui --export-width=1280 --export-png=`echo $1 |sed -e 's/svg$/png/'` $1






                          share|improve this answer












                          share|improve this answer



                          share|improve this answer










                          answered Jun 22 '17 at 13:23









                          Serge StroobandtSerge Stroobandt

                          2,1812034




                          2,1812034






























                              draft saved

                              draft discarded




















































                              Thanks for contributing an answer to Ask Ubuntu!


                              • Please be sure to answer the question. Provide details and share your research!

                              But avoid



                              • Asking for help, clarification, or responding to other answers.

                              • Making statements based on opinion; back them up with references or personal experience.


                              To learn more, see our tips on writing great answers.




                              draft saved


                              draft discarded














                              StackExchange.ready(
                              function () {
                              StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f209449%2fis-there-a-way-to-batch-export-svgs-to-pngs%23new-answer', 'question_page');
                              }
                              );

                              Post as a guest















                              Required, but never shown





















































                              Required, but never shown














                              Required, but never shown












                              Required, but never shown







                              Required, but never shown

































                              Required, but never shown














                              Required, but never shown












                              Required, but never shown







                              Required, but never shown







                              Popular posts from this blog

                              Mouse cursor on multiple screens with different PPI

                              Agildo Ribeiro

                              Sometime when accessing a menu: “Ubuntu 16.04 has experienced an internal error”