Skip to content

Instantly share code, notes, and snippets.

@tomaszj
Last active May 25, 2022 14:26
Show Gist options
  • Save tomaszj/fe25e368d860fb399987a697c70369e4 to your computer and use it in GitHub Desktop.
Save tomaszj/fe25e368d860fb399987a697c70369e4 to your computer and use it in GitHub Desktop.
Script that can be pasted into GIMP's Python-Fu console to generate multiple files with names from the array.
names = [
"Ada Lovelace",
"John Smith",
"Sam Kowalski"
]
original_image = gimp.image_list()[0]
for name in names:
first_name, last_name = name.split(" ")
text_layer_string = first_name + "\n" + last_name
filename = "{}-{}.png".format(first_name.lower(), last_name.lower())
image = pdb.gimp_image_duplicate(original_image)
text_layer = pdb.gimp_image_get_layer_by_name(image, "Name")
pdb.gimp_text_layer_set_text(text_layer, text_layer_string)
pdb.gimp_text_layer_set_font_size(text_layer, 72, 0)
pdb.gimp_text_layer_set_font(text_layer, "Helvetica Neue Light")
merged_layer = pdb.gimp_image_merge_visible_layers(image, 1)
pdb.file_png_save_defaults(image, merged_layer, "/Users/tomaszj/Documents/gimp-output/" + filename, filename)
pdb.gimp_image_delete(image)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment