I have a very large SVG file in inkscape. I want to export a series of PNG tiles that are slices of this image. I know I could export the whole document as a PNG and use some other tool to slice it, or I could manual export 512x512 pixel sections of the document using Export Bitmap. I just wondered if there was any kind of scripting interface I could use to automate that process and export all the bitmaps I need.
I suppose I could write a batch file to call inkscape with command line interface to export all the sections but that seems hugely inefficient to have to relaunch inkscape over and over and parse the hug SVG file each time.
Any ideas?
Automated image slicing
Re: Automated image slicing
- the Inkscape 'Export Bitmap…' dialog supports slicing:Inkscape Manual wrote:Slicing a Drawing
To slice a drawing into pieces for use on the web, you can create an array of hidden rectangles (no Stroke or Fill) in a separate “export” Layer. Save each rectangle one time to define the export filename (or change each rectangle “Id” with the Export Bitmap dialog prior to any exporting). Then when it is time to export the drawing, go to the “export” layer, use the command Edit → Select All (Ctrl+A) to select all the rectangles in the Layer, then do a batch export. - there's an Inkscape Slicer extension:matt wrote:Here's the process I've used for slicing web layout with Inkscape. Create your webpage layout (set page units to "px", width/height appropriately and snap to 1 pixel intervals. This should allow pixel perfect alignment). Then create a new layer, naming it slices. Draw rectangles over the areas you want to slice (set x,y,width,height to whole pixel values). Name these rectangles using the Object Properties found in the right click contextual menu (the saved images name will be based on that value, so name them something like "header" instead of the default/non-useful "rect4312").
What the plugin then does is iterate over all of the rectangle definitions found in the slice layer and set the opacity of the slice rectangle to 0. (That allows you to make slightly transparent slices, which are easier to deal with than invisible ones) It then creates pngs for every slice. After completing the slicing, it then sets all the slice rectangles to red at 25% opacity. To continue working on your design without having to deal with the slices being selected, just "lock" the slice layer and your clicks should fall through. You can also click the "eye" on the slice layer to not view it.