Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

APNG frames are cut off when saving #6672

Closed
BootsManOut opened this issue Oct 20, 2022 · 5 comments
Closed

APNG frames are cut off when saving #6672

BootsManOut opened this issue Oct 20, 2022 · 5 comments

Comments

@BootsManOut
Copy link

BootsManOut commented Oct 20, 2022

When exporting animated PNG files as APNG, based of a PNG image sequence, it cuts 2 frames in half.

Here is the code I use:

import PIL
from PIL import Image as Img
from os import walk

mypath="original character folder"

#import files:
files = []
for (dirpath, dirnames, filenames) in walk(mypath):
    files.extend(filenames)
    break
#import as PIL image:
images = []
for f in files:
    images.append(Img.open(mypath+"/"+f))

#Export as APNG:
images[0].save("exportfolder/exportimage.apng", disposal=2, save_all=True,
                                      append_images=images[1:], loop=0,
                                      duration=200, optimize=False, lossless=True)

The original images contain all frames. When exported as gif you can see all frames:
characters animation

And this is what it looks like exported as animated APNG:
exportimage animation

Here you can use this folders and place them in the project folder to test it out:
original character folder and export folder containing apng export file.zip

@radarhere
Copy link
Member

I don't expect it to make a difference, but just for clarity - your 'original character folder' in the zip contains 'characters animation.00 animation.gif'. That was a mistake, yes?

@BootsManOut
Copy link
Author

BootsManOut commented Oct 20, 2022

Yes, sorry, I still had the gif export in that folder. I updated the file, thanks for pointing it out!

@radarhere radarhere changed the title APNG export does not work (Frames are being cut off) APNG frames are cut off when saving Oct 20, 2022
@radarhere
Copy link
Member

I've found that if you remove disposal=2 from your code, the image appears correctly.
exportimage

@BootsManOut
Copy link
Author

BootsManOut commented Oct 23, 2022

Okay, awesome!
From what I read online, I understood the disposal should do the same as the disposal in gif files, but I assume that's not the case?
I found the 'blend' argument would do for APNG what 'disposal' does for gifs.

I'm not sure if disposal=2 is supposed to cut frames in half like that for APNGs, but from my side the issue is resolved anyways, by removing the argument as you said.

Thank you very much for your help, @radarhere !

@radarhere
Copy link
Member

When running your original code, I noticed that the first frame was empty. I've created PR #6683 to fix that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants