我正在使用魔杖基本上对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)
答案 0 :(得分: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)
希望有所帮助!