-
-
Save zeffii/9d74e96912359bded61b to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
load directory as layers | |
export as gif, animated | |
-i -d -f -s | |
""" | |
import math | |
import os | |
# from gimpfu import * | |
def path_iterator(path_name): | |
for fp in os.listdir(path_name): | |
if fp.endswith(".png"): | |
yield fp | |
def export_dir_as_GIF(path_name): | |
# first load one image | |
fp = "/home/zeffii/Desktop/bar.png" | |
iref = pdb.file_png_load(fp, fp) | |
# get image dimensions, start assembling new image | |
width, height = iref.width, iref.height | |
img = gimp.Image(width, height, RGB) | |
img.disable_undo() | |
# for file in directory | |
for fp in path_iterator(path_name): | |
r = pdb.file_png_load(fp, fp) | |
l = gimp.Layer(r, r.name, width, height, RGB_IMAGE, 100, NORMAL_MODE) | |
img.add_layer(l, 0) | |
drw = pdb.gimp_image_active_drawable(img) | |
# name the image according to the name of the host folder | |
pfix = "_animated" | |
animation_name = os.path.basename(os.path.dirname(path_name)) + pfix | |
save_name = os.path.join(path_name, animation_name) | |
pdb.file_gif_save(1, img, drw, save_name, animation_name, 1, 1, 100, 2) | |
gimp.delete(img) | |
# print_png_names("/home/zeffii/Desktop/") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment