3
votes

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:

Original image

And here is the output from Wand:

Resized with Wand

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

Resized with ImageMagick

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?

1

1 Answers

0
votes

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.