GIMP Chat
http://gimpchat.com/

Seamless Gif Animation plug-in
http://gimpchat.com/viewtopic.php?f=9&t=20359
Page 1 of 1

Author:  trandoductin [ Thu Apr 13, 2023 9:36 am ]
Post subject:  Seamless Gif Animation plug-in

Just saving it here for future reference if I need to use it.
It just runs on an animated gif (that's in RGB mode) and produces overlay fades so that it animates seamlessly.
from gimpfu import *
import random
import math
def python_loop_gif_tt(image, layer):
   pass
   #return
   new_image = pdb.gimp_image_new(image.width,image.height,RGB)
   display_new = pdb.gimp_display_new(new_image)
   total_layers = len(image.layers) #120 when first tested
   mid_layer = total_layers/2

   bottom_layer = total_layers
   for i in range(bottom_layer,mid_layer,-1): #loop from bottom layer to midlayer
      lower_layer = pdb.gimp_layer_new_from_drawable(image.layers[i-1],new_image)
      pdb.gimp_image_insert_layer(new_image,lower_layer,None,0)
      upper_layer = pdb.gimp_layer_new_from_drawable(image.layers[(i-1+mid_layer)%total_layers],new_image)
      pdb.gimp_image_insert_layer(new_image,upper_layer,None,0)
      pdb.gimp_layer_set_opacity(upper_layer,min(100,(i-mid_layer)*100/mid_layer)) #this goes from fades from 100 to 0
      pdb.gimp_image_merge_down(new_image,upper_layer,CLIP_TO_IMAGE)
   for i in range(mid_layer,0,-1): #loop from mid layer to first layer
      lower_layer = pdb.gimp_layer_new_from_drawable(image.layers[i-1],new_image)
      pdb.gimp_image_insert_layer(new_image,lower_layer,None,0)
      upper_layer = pdb.gimp_layer_new_from_drawable(image.layers[(i-1+mid_layer)%total_layers],new_image)
      pdb.gimp_image_insert_layer(new_image,upper_layer,None,0)
      pdb.gimp_layer_set_opacity(upper_layer,100-min(100,(i*100/mid_layer))) #this goes from 0 to 100
      pdb.gimp_image_merge_down(new_image,upper_layer,CLIP_TO_IMAGE)

register(
   "python_fu_loop_gif_tt",
   "Loop Gif",
   "Loop Gif",
   "Tin Tran",
   "Tin Tran",
   "November 2022",
   "<Image>/Python-Fu/Loop Gif",             #Menu path
   "RGB*, GRAY*",
   [
   #(PF_BRUSH, "brush", "Brush:", 0),
   #(PF_SPINNER, "brush_size", "Brush-size:", 25, (1, 1000, 1)),
   #(PF_SPINNER, "brush_spacing", "Brush-spacing:", 5, (1, 1000, 1)),
   #(PF_SPINNER, "offset_angle", "Offset angle (angle to offset from path's angles):", 0, (0,360, 1)),
   #(PF_TOGGLE, "random_angle",   "Use random angle (when doing generally round blotches):", 0),
   #(PF_SPINNER, "px_height", "Height of each tile image:", 100, (1, 1000, 50)),
   ],
   [],
   python_loop_gif_tt)

main()

Page 1 of 1 All times are UTC - 5 hours [ DST ]
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
http://www.phpbb.com/