Inkscape.org
Beyond the Basics SVG to PNG batch convert
  1. #1
    meetdilip meetdilip @meetdilip

    Hi, I am trying to convert a folder full of SVGs to PNG of 256x256 canvas. A folder like this
     

    As you can see, the SVG has many sizes in a single file. I only intend to use the bigger one. Attaching a sample SVG.

    It would be great if I can skip exporting them one by one.

  2. #2
    inklinea inklinea @inklinea⛰️

    In Inkscape each icon size is framed by a rectangle object. These rectangles appear to be frames sizes 24x24 48x48 .. 256x256.

    inkscape --actions="select-by-selector:[width='256'];select-list;" ebook-reader-app.svg

    Then you can use the id returned with FitCanvasToSelection and export-filename export-area-page and export-do

    https://www.w3schools.com/css/css_attribute_selectors.asp

    or maybe just try to find a repository like this one :) https://github.com/snwh/suru-icon-theme/tree/master/Suru/256x256

  3. #3
    meetdilip meetdilip @meetdilip

    Thanks @inklinea

    inkscape --actions="select-by-selector:[width='256'];select-list;" ebook-reader-app.svg

     

    We will have to do it for each icon, right? I am ok with simply exporting the page ( keeping it 256x256 ) with icon in it. Maybe I read the post wrong. Wondering how to " batch " convert this one.

    Thanks for the repo link. :)

  4. #4
    inklinea inklinea @inklinea⛰️

    inkscape --batch-process --export-type=png --actions="select-by-selector:[width='256'];FitCanvasToSelection;export-do;" *

  5. #5
    meetdilip meetdilip @meetdilip

    Thanks :)

     

    You were right about the repo as well. :+1