1
votes

I'm working with wand to basically do a frame-by-frame translation of a gif. I want to transpose an image into each frame of a gif, then save the output animated gif.

def placeImage(gif_name, image_name, save_location):
  with Image(filename = gif_name) as gif:
    with Image(filename = image_name) as image:
      new_frames = []
      for frame_orig in gif_new.sequence:
        frame = frame_orig.clone()
        with Drawing() as draw:
          draw.composite(operator='src_over', left=20, top=20,
            width=image.width, height=image.height, image=image)
          draw(frame)
          new_frames.append(frame)

So now I've got all of these frames (though they're not SingleImage objects, but Image objects) that I'd like to put back together and generate a new gif. Any advice?

I'd like to be able to do something like:

with gif.clone() as output:
    output.sequence=new_frames
    output.save(filename=save_location)
1

1 Answers

0
votes

I just answered something very similar here: Resizing GIFs with Wand + ImageMagick

with Image() as dst_image:
    with Image(filename=src_path) as src_image:
        for frame in src_image.sequence:
            frame.resize(x, y)
            dst_image.sequence.append(frame)
    dst_image.save(filename=dst_path)

Hope that helps!