1

我正在使用 wand 基本上对 gif 进行逐帧翻译。我想将图像转置到 gif 的每一帧中,然后保存输出的动画 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)

所以现在我已经得到了所有这些帧(虽然它们不是 SingleImage 对象,而是 Image 对象),我想将它们重新组合在一起并生成一个新的 gif。有什么建议吗?

我希望能够做类似的事情:

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

1 回答 1

0

我刚刚在这里回答了一些非常相似的问题: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)

希望有帮助!

于 2016-04-25T10:16:16.857 回答