使用Wand + ImageMagick调整GIF大小 [英] Resizing GIFs with Wand + ImageMagick

查看:247
本文介绍了使用Wand + ImageMagick调整GIF大小的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用),GIF正确调整大小,符合预期:





这我目前正在调整图像的大小:

  with image(filename =src.gif)as img:
img.resize(50,50)
img.save(dest.gif)



<我也试过了通过每个框架进行分类并单独调整大小:

 使用Image(filename =src.gif)作为img:
for img.sequence中的帧:
frame.resize(50,50)
frame.destroy()
img.save(dest.gif)

两者都产生与上面相同的结果。我做错了什么?

解决方案

您可以尝试打开新目标图像并将每一帧循环到:

 使用Image()作为dst_image:
with Image(filename = src_path )作为src_image:
for src_image.sequence中的帧:
frame.resize(x,y)
dst_image.sequence.append(frame)
dst_image.save(filename = dst_path )

适合我。


I am using Wand 0.3.7 with ImageMagick 6.8.8-10 to batch-resize some animated GIF files I have. But for some reason, Wand only resizes one frame in the image, leaving the others at their original size.

Here is the original image I am trying to resize:

And here is the output from Wand:

If I use ImageMagick from the command line directly (following instructions from here), the GIF is correctly resized, as expected:

This is how I am currently resizing the image:

with Image(filename="src.gif") as img:
    img.resize(50, 50)
    img.save("dest.gif")

I have also tried iterating through each frame and resizing them individually:

with Image(filename="src.gif") as img:
    for frame in img.sequence:
        frame.resize(50, 50)
        frame.destroy()
    img.save("dest.gif")

Both produce the same result seen above. What am I doing wrong?

解决方案

You might try opening a new target Image and loop every frame into that:

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)

works for me.

这篇关于使用Wand + ImageMagick调整GIF大小的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆