Skip to content

Instantly share code, notes, and snippets.

@RafaelOliveira
Last active April 21, 2017 08:32
Show Gist options
  • Save RafaelOliveira/309a3acd872a83b3959c835c06920d96 to your computer and use it in GitHub Desktop.
Save RafaelOliveira/309a3acd872a83b3959c835c06920d96 to your computer and use it in GitHub Desktop.
Python script for Gimp to save the layers info in a file like a texture atlas
#!/usr/bin/python
# How to use:
# In Windows and Linux there is .gimp-xx folder in your home folder
# save the file in .gimp-xx/plug-ins/
# For Mac search in Google where to save Gimp plugins
# The menu is Image -> Save layer atlas
from gimpfu import *
def layer_atlas(timg, tdrawable, file_path):
atlas_file = open(file_path, "w")
for layer in timg.layers:
if layer.visible:
atlas_file.write("{};{};{};{};{}\n".format(layer.name, layer.offsets[0], layer.offsets[1], layer.width, layer.height))
atlas_file.close()
register(
"python_fu_layer_atlas",
"Save the layer positions and size like a texture atlas",
"Save the layer positions and size like a texture atlas",
"Rafael Oliveira",
"Rafael Oliveira",
"2017",
"<Image>/Image/Save layer atlas",
"RGB*, GRAY*",
[
(PF_FILE, "file_path", "Path of the file", "")
],
[],
layer_atlas)
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment