![]() A layer with name layer3 inside a group with name group2, which is inside.A layer with name layer2 inside a group with name group1 will be exported.A layer with name layer1 will be exported as layer1.png.Save sprite: If checked, the full sprite will be saved in the output.The resolution of the file willīe multiplied by this number. Export scale: The scale at which to export.Export format: File format of exported files. ![]() Group separator: The character used to separate the group names in file name.File name: The name of every exported file.This is because Aseprite’s API doesn’t support folder Note that you will specify aįile, not a folder. Output directory: The folder where to export.Execute the script and your layers will export in separate files. Have your sprite with multiple layers you want to be exported individually. I couldn’t find this feature, so I investigated and found that there is an api for Aseprite, so I made my own script that does just that before making sure there was no way to do it other way. As I was making these sprites I started to miss a function to export all layers on a sprite as individual png images with their own name and on a specific folder. I’m working on a game where characters are drawn in layers, so you can choose their clothes and complements. I found 300 kept the resolution in the layers of my original XCF file but your mileage may vary.An easy and fast way of exporting every layer of a sprite into individual sprites. The -r option is the resolution and presumably this should match whatever default GIMP is set when exporting to PDF files. out_01.png, out_01.png etc.): pdftoppm -png -r 300 exported_layers.pdf out_ Use the command line tool pdftoppm to export as PNG files.įor example, if you were to export the XCF file as the file exported_layers.pdf, the following will create each layer as it's own PNG image with the prefix out_ (e.g.Make sure to de-select Omit hidden layers and layers with zero opacity.Make sure to de-select Convert bitmaps to vector graphics where possible.Make sure to de-select Apply layer masks before saving.Make sure to select Layers as pages (bottom layers first).Export the XCF file as a PDF ( File -> Export as) with the following in mind:.Many years later, GIMP has removed the functionality from the accepted solution and some of the other code solutions have succumbed to code rot (I'm unable to run the GIMP exporter with Python3).Īs this is one of the first hits from Google when asking how to export layers from GIMP to their own PNG files, I feel duty bound to provide an updated answer. If the Gimp's version of Python doesn't support f-strings (Python 3.6 ), this is exactly equivalent: outname = "Layer. That'll write the layers into PNG files named "Layer 000.png" through "Layer 999.png" (or however many layers are present, if fewer than 1000). Just replace the final loop above with something like: for n, lay in enumerate(img.layers): Caveat GIMPtor.Įdit: If you do have same-named layers, you could easily ignore the names and instead write out the layers in numbered files. If any of your layer names are the same, that is a problem, because this will happily overwrite any previously-written files. (Which must already exist, otherwise add an os.makedirs(outpath, exist_ok=True) before the loop.) You'll see the progress meter in the image window's status bar start whipping through all of your layers, writing each one to a PNG file of the same name, in whatever directory you specified as outpath. # type an extra newline to exit the indented block Savefn(img, lay, os.path.join(outpath, outname), outname) # Even if your layer names contain spaces, not a problem Outpath = "/home/$USER/Pictures" # (or r"C:\Users\$USER\Pictures", etc) # If you have multiple images open, you may need to adjust The best thing about ThorSummoner's answer is that it called attention to the OpenRaster export plugin, which as it turns out lives in the file file-openraster.py in the GIMP installation.īy reading its code (and with some assistance from the built-in procedure browser), I was able to determine that the layers of a GIMP XCF can be saved to individual PNGs by going to Filters > Python-fu > Console in the interface, and entering the following into the built-in Python interpreter: import os
0 Comments
Leave a Reply. |