Coder Social home page Coder Social logo

batch-export's Introduction

logo

This extension will help you export your work easier:

  • Supports multiple export file formats (SVG, PNG, PS, EPS, PDF, EMF, WMF, XAML).
  • Export each layer as a separate file.
  • Choose which layers to export.
  • Automated file naming.
  • Configure background layers.

Inkscape view

Install

Download this project and copy the extension files (batch_export.inx and batch_export.py) to the config path of your Inkscape installation.

One simple way of finding the config path is to open Inkscape and go to Edit > Preferences > System. The path will be listed in the User extensions field. Make sure you restart Inkscape after you copied the extension files at the desired location and the extension will be available in the extensions menu.

Linux

The default path on Linux is:

~/.config/inkscape/extensions

If you installed the flatpak version:

~/.var/app/org.inkscape.Inkscape/config/inkscape/extensions

Windows

The path on Windows 10 is this:

C:\Users\[yourWindowsusername]\AppData\Roaming\inkscape\extensions

If you don't see the AppData folder, you need to set the windows explorer to show hidden files.

Usage

After the extension is installed, it can be found in the Extensions menu, Export submenu.

Controls

  • Export parameters

    • In this section, you can choose to export the layers at your desired location.
    • The output files can be exported in one of the following formats: SVG, PNG, PS, EPS, PDF, EMF, WMF, XAML.
    • If you want to export the files in PDF format you can choose the PDF version to be used(1.4 or 1.5).
    • Choose a layer export mode (this feature is independent from the Use background layers):
      • Export each layer as a single layer - the export file will contain only the objects from this layer
      • Use parent layers as background layers - the export file will contain the objects from the parent layers as well
  • Other options

    • Check the Use background layers options if you want to have one or more layers that will appear in all exports. You also need to name these layers with a fixed tag at the beginning.
    Ex. [fixed] Background
    
    • If you have any layers that you don't want to be exported, just hide them in the layer panel of Inkscape and then turn on the Skip hidden layers option. This way you can have other testing or mockup layers in your file and still be able to export all the others.
    • If in the export path there are any other files with the same name as one of the exported files, the extension will not overwrite that file, therefore not exporting that particular layer(s). If you don't want this behaviour you can turn on the Overwrite existing files option. This option is turned off by default to make sure you don't lose any files by mistake.
    • Choose the export plain SVG option to remove any Inkscape-specific SVG attributes/properties.
    • Using clones - select this option if you are using clones in your document, otherwise only the original object will appear in the exported files.

      Selecting this option will result in larger file sizes, so I recommend using the following method instead if you can:

      1. Create a copy of your Inkscape file so that you don't mess with your current file. (Or simply create a backup as this will break your clones)
      2. Select all objects (Ctrl+Alt+A or Edit->Select All in All Layers should work if there are no locked layers) and use the option Edit->Clone->Unlink Clones recursively.
      3. Use the extension as previously intended, without selecting the "using clones" option.

Export size

On the second page you can configure both the area that is exported and the size and resolution of the output file(if it supports it).

  • Export area
    • Page - Area to export is page.
    • Drawing - Area to export is whole drawing (ignoring page size).
    • Custom - Define a custom area to export in SVG user units.
  • Export resolution
    • Default - no custom options.
    • Custom DPI - Resolution for bitmaps and rasterized filters.
    • Custom size - Set width and height of the output file.

File naming

On this page you can choose on of the two systems that can be used for naming files.

  • Simple naming

    • This is the default system used to name the exported files.
    • Each file is named the same as each layer.
    • Optionally, you can choose to number each file. The number will prefix the layer name.
  • Advanced naming

    • This naming system will allow you more freedom in naming the exported files, but you have to make sure the names will have a correct format according to your OS.
    • It works by using a user defined custom naming scheme composed of tags and text.
    • Available tags
      • [LAYER_NAME] - it will be replaced by the name of each layer.
      • [NUM] - it will be replaced by an automatically increasing number.
      • [NUM-1] - same as [NUM], but the numbers range between [1, .., 9].
      • [NUM-2] - same as [NUM], but the numbers range between [01, .., 99].
      • [NUM-3] - same as [NUM], but the numbers range between [001, .., 999].
      • [NUM-4] - same as [NUM], but the numbers range between [0001, .., 9999].
      • [NUM-5] - same as [NUM], but the numbers range between [00001, .., 99999].
      • Be aware! For example, if you use [NUM-2] to export more than 99 layers, the numbers above 99 will increase normally but they will not keep the same 2 digit syle format. This applies for all [NUM-number] tags and their respectiv max limit.
    • Apart from tags, you can also enter any custom text that you want
    • Examples of custom naming schemes
      • [NUM] [LAYER_NAME] will result in "1 layer 1.svg", "2 layer 2.svg".
      • design [NUM-2] will result in "desing 01.svg", "design 02.svg".
      • [NUM] haha [LAYER_NAME] -hello- [NUM-4] will result in "1 haha layer 1 -hello- 0001.svg" (I don't know why would you want to do something like this, but you can :) ).

Help

On this page you can access the logging function of the extension. You can turn on this option and the extension will create a log file at the log file path. If a log file already exists, it will add the new logs at the end of that file. You can optionally choose to overwrite the existing log file. This may be useful if you try to debug the extension or see a more in-depth log of its actions, although I recommend checking the source code for that :).

Result

This is the result of using the extension to export the layers of the file shown in the first screenshot. In that file, I have one background layer containing a red rectangle, one testing layer that is hidden and five layers that I want to export.

Exported files

Disclosure: Each exported file will only contain the data corresponding to that specific layer and background layers only.

Explanation: An SVG file can contain data that is not visible when displayed as an image. There can be multiple hidden layers in the file, that will not show up when opened with an image viewer, but still take up space in the file. For example, you cand have a file with two layers, layer1 containing a rectangle and layer2 containing a circle. If you hide layer1, save the file as an SVG and open it with an image viewer, only the circle will be displayed, however, the layer containing the rectangle is still in the file, but the image viewer knows not to display it. That means, not only that your file will have a size bigger than it needs to, but will also contain private data that you may not wish to save or share with others.

This extension will keep the exported files to minimum size and keep your data private by exporting only the visible data of your work.

Notes

This extension works with Inkscape 1.0.

  • ✔️ Linux - I have tested it on Linux, using both the version from the ubuntu ppa and the flatpak one.
  • ✔️ Windows 10 - I have also tested it on Windows 10 with both the version from the Inkscape website and the one from the Microsoft Store.
  • macOS - I do not own any Apple devices, so I cannot tell you if it will work on macOS, although I don't think there might be any compatibility issues. If you have a macOS device, please try it and let me know.

License

This project is licensed under the MIT license.

Become a supporter 🙌

Help in maintaining this project by giving me a cup of coffee :)

paypal

batch-export's People

Contributors

adamnejm avatar stefantraistaru avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

batch-export's Issues

No Export Content on Windows 10

I get a crash when I export my drawing on windows 10. I'm exporting layers as SVG's. The files appear to get written but with no contents, here is one of the output files:

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<svg
   xmlns:dc="http://purl.org/dc/elements/1.1/"
   xmlns:cc="http://creativecommons.org/ns#"
   xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
   xmlns:svg="http://www.w3.org/2000/svg"
   xmlns="http://www.w3.org/2000/svg"
   width="79.110741mm"
   height="280.30972mm"
   viewBox="0 0 79.110741 280.30971"
   version="1.1"
   id="svg8">
  <defs
     id="defs2" />
  <metadata
     id="metadata5">
    <rdf:RDF>
      <cc:Work
         rdf:about="">
        <dc:format>image/svg+xml</dc:format>
        <dc:type
           rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
        <dc:title />
      </cc:Work>
    </rdf:RDF>
  </metadata>
</svg>

Here is the attached drawing I am using.
EuroPlate_Art_and_Cuts.zip

Settings:
image

Inscape Version:
image

Thanks for you help,
Trevor

Recognise the background colour set in document properties.

It would be really good to have this plug-in recognise the background colour and opacity set in document properties.

Currently all exports have a transparent background unless you use a fixed layer. This adds an extra layer of work which seems a bit unnecessary given that the background colour setting already exists in the file.

When you export a png from inkscape using the command line, the default is for the background to be as set in the document properties - so I'm not sure why this is not happening in the extension. Are the document properties being deleted at some point?

I had a quick look through the code but don't know the API well enough to understand where it's going wrong.

Clones are invisible after batch export

Clones of objects are not exported, only their original source are exported.
This way of all my 8 layers only the first one shows all objects. The other layers do not
contain the cloned objects from the first layer.

Export fail when layer are too big

Hi,

I have some trouble when exporting layers that are big.

Here is the SVG : SVG FILE
Here is the log file : batch_export.log

If I try to export Layer 1 it will crash. Other layers are fine. I checked that the tmp file was create and there is no problem on this side.

I've try to export as PDF1.4 and PDF 1.5 and I have the same issue
I also notice an inkscape process that get stuck and seems to do nothing :
image

After some further testing, it seems that this is not related to the size of the Layer as I could export a Layer that was 3mb while the Layer 1 in my example file should not exceed 1mb.

Edit : After some more testing. Once the process is stuck, I tried to manually run the Inkscape command given by the log file. And it is working. I have no idea why the first execution of the command would get stuck ?

Thank you very much for the

Billel

Document background color not taken into account for SVG

Hello thanks for this very good plugin.

When exporting layers to PNG, the document's background color, when non-transparent, is still interpreted as transparent in the output PNGs.
Example of output with transparent PNG background despite non-transparent source Inkscape SVG background.
youwin-02

How to reproduce:

  • download and open this SVG file: youwin_spritesheet.zip
  • use current master branch plugin
  • delete the the '[fixed] background' layer
  • export to PNG at 884 x 497 defined size
  • notice a transparent background in each exported file

Circumventing way:

  • create a '[fixed] Background' layer as stated in the README, and tick the 'Use background layers' checkbox before export.

About: Used for p5js video game https://github.com/myselfhimself/BerlinWallBreaker/ for the You Win last screen's sprites

Controls Tab Missing Options

Just installed tis extension but the Controls Tab is missing options and when I try to run it, I get an error.
image
image

Unknown error when exporting (from converted groups to layers)

Hi. In before, thank you for your work in this tool, it's saving many time and simplifying work!
But anyway, seems like there's an error (and i don't know what this error telling about):

Traceback (most recent call last):
File "D:\Data\Inkscape\share\inkscape\extensions\batch_export.py", line 339, in
_main()
File "D:\Data\Inkscape\share\inkscape\extensions\batch_export.py", line 335, in _main
exporter.run()
File "D:\Data\Inkscape\share\inkscape\extensions\inkex\base.py", line 131, in run
self.save_raw(self.effect())
File "D:\Data\Inkscape\share\inkscape\extensions\batch_export.py", line 175, in effect
temporary_file_path = self.manage_layers(layer_id, show_layer_ids, options.hierarchical_layers, options.using_clones)
File "D:\Data\Inkscape\share\inkscape\extensions\batch_export.py", line 264, in manage_layers
layer_label = layer.attrib["{%s}label" % layer.nsmap['inkscape']]
File "src/lxml/etree.pyx", line 2479, in lxml.etree._Attrib.getitem
KeyError: '{http://www.inkscape.org/namespaces/inkscape}label'

I was trying to export my svg with multiple layers as a page (and later i will combine it to make booklet pdf). Before, i was using another exporter but when i found your extension, i wanna to try out (the former exporter i use utilize groups to export, so i converted the groups to layers from objects menu)

Do you know what's this error about and/or do you know how to solve/workaround this?

I'm using Inkscape 1.1 in Windows 11 21H2 22000.376

Thank you!

no plugin the program

After copying the files, I do not have this plug-in in the program and I did not change the default location

Export PDF Text as Path

When exporting as PDF would be possible to convert the text to paths? (Like in the standard Save As option)
image
Matteo

Batch export on ma

Hello,
I work on mac and have tried Batch export. I am not an expert at all but this export feature would really speed up my work... So Batch export runs but the files are not visible in Finder. In Inkscape > Open File they are however visible but open in Inkscape (which is not the idea of exporting .png files...) Is there any mistake I made? Thank you!

[FEATURE] Additional Tags in Name Templates

Export file name templating would benefit from additional tags. Such as:

  • [HEIGHT]: Exported file pixel height
  • [WIDTH]: Exported file pixel width
  • [DATE]: Export date in YYYY-MM-DD format

Plugin doesn't respect layer-inherited hidden/visible property

First of all thank you for your plugin it's been such a life saver for me many times!

Issue: I've got several layers with included layers inside(I suppose it is called hierarchical layers). These top layers are essentially almost carbon copies with few tweaks here and there. I'm trying to export those layers using "skip hidden layers" checkbox but the plugin somehow ignores that checkbox on sub-layers(layers that are "inside" a main layer) and proceed to export every sub-layer ignoring the fact the parent layer is invisible.

What was even more confusing is that since these top layers are copy of one another I haven't been able to pinpoint what's going on since hidden layers were overwriting shown layers.

But after some experimentation I've found the root of the problem: even if a parent layer is hidden the plugin goes on and export sub-layers as-is ignoring parent's visibility.

Hot to Reproduce:

  1. Create a new file
  2. Create "layer 1"(names are not important obviously)
  3. Create "layer 2" and move in inside "layer 1"
  4. Create any path or shape on "layer 2"
  5. Click hide icon(an eye) on "layer 1"
  6. try to export with "skip hidden layers" ticked

Expected result: Nothing will be exported since there are no layers visible
Observed result: "Layer 2" will be exported(since it got it's visibility flag on)

inkscape 1.1.

I'm including a test file as well.

test_batchExport.zip

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.