vault backup: 2024-03-20 10:21:50

Affected files:
.obsidian/workspace.json
GIMP Scripting.md
This commit is contained in:
ed barz 2024-03-20 10:21:50 +01:00
parent 6b58fa8379
commit 8bd719ca80
2 changed files with 62 additions and 5 deletions

View File

@ -31,6 +31,18 @@
}
}
},
{
"id": "4aa18cc5a778b7ef",
"type": "leaf",
"state": {
"type": "markdown",
"state": {
"file": "GIMP Scripting.md",
"mode": "source",
"source": false
}
}
},
{
"id": "22a1e3cf3ac1bdc2",
"type": "leaf",
@ -108,7 +120,7 @@
"state": {
"type": "backlink",
"state": {
"file": "Corbia spider.md",
"file": "GIMP Scripting.md",
"collapseAll": false,
"extraContext": false,
"sortOrder": "alphabetical",
@ -125,7 +137,7 @@
"state": {
"type": "outgoing-link",
"state": {
"file": "Corbia spider.md",
"file": "GIMP Scripting.md",
"linksCollapsed": false,
"unlinkedCollapsed": true
}
@ -148,7 +160,7 @@
"state": {
"type": "outline",
"state": {
"file": "Corbia spider.md"
"file": "GIMP Scripting.md"
}
}
},
@ -191,11 +203,12 @@
"copilot:Copilot Chat": false
}
},
"active": "22a1e3cf3ac1bdc2",
"active": "4aa18cc5a778b7ef",
"lastOpenFiles": [
"Corbia spider.md",
"GIMP Scripting.md",
"Untitled.md",
"Niche Fragrence.md",
"Corbia spider.md",
"Docker.md",
"Weaviate.md",
"Install neo4j on Debian.md",

44
GIMP Scripting.md Normal file
View File

@ -0,0 +1,44 @@
## How to export every layer as single image
```python
import os
import gimpfu
def export_layers(image, drawable):
image_uri = gimpfu.pdb.gimp_image_get_uri(image)
image_path = image_uri[7:] # Removing 'file://' from the URI
output_folder = os.path.dirname(image_path)
if output_folder and os.path.exists(output_folder):
for i, layer in enumerate(image.layers, start=1):
filename = "layer_{:03}.png".format(i)
filepath = os.path.join(output_folder, filename)
tmp_image = gimpfu.pdb.gimp_image_new(image.width, image.height, image.base_type)
layer_copy = gimpfu.pdb.gimp_layer_new_from_drawable(layer, tmp_image)
gimpfu.pdb.gimp_image_insert_layer(tmp_image, layer_copy, None, 0)
gimpfu.pdb.file_png_save_defaults(tmp_image, layer_copy, filepath, filename)
gimpfu.pdb.gimp_image_delete(tmp_image)
else:
gimpfu.gimp_message("Please save the image first to determine the output directory.")
def register_export_layers():
gimpfu.register(
"python_fu_export_layers",
"Export all layers",
"Exports all layers as separate PNG files",
"Your Name", "Your Name", "2024",
"Export Layers...",
"*", # This makes the script available for all types of images
[
(gimpfu.PF_IMAGE, "image", "Input image", None),
(gimpfu.PF_DRAWABLE, "drawable", "Input drawable", None),
],
[],
export_layers,
menu="<Image>/File/Export/"
)
gimpfu.main()
register_export_layers()
```