Too expensive to process. Imagemagick doesn't support APNG, so it'd require apngasm or some other external tool, and was deemed not important enough or something. I tried to make sense of these tools but gave up eventually as it seems there is no stable version. If someone's willing to look into it and write pull request and install instruction, it might get included, though.
Too expensive to process. Imagemagick doesn't support APNG, so it'd require apngasm or some other external tool, and was deemed not important enough or something. I tried to make sense of these tools but gave up eventually as it seems there is no stable version. If someone's willing to look into it and write pull request and install instruction, it might get included, though.
Doesn't use any libraries, just reads the raw PNG chunk headers and looks for the animation control chunk, which all APNGs should have, based on the Wikipedia page for APNG. Returns 0 for APNG, 1 for non-animated PNG, 2 for not a PNG at all, and 3 if there's some error, so it's usable in a shell script, for example.
Note that it has pretty much zero error handling. A malformed PNG could very easily crash it. It is a proof of concept only. But I could make something real, if there's interest.
Also worth noting that it could easily work on a stream if necessary. It only needs to seek forward.
Doesn't use any libraries, just reads the raw PNG chunk headers and looks for the animation control chunk, which all APNGs should have, based on the Wikipedia page for APNG. Returns 0 for APNG, 1 for non-animated PNG, 2 for not a PNG at all, and 3 if there's some error, so it's usable in a shell script, for example.
Note that it has pretty much zero error handling. A malformed PNG could very easily crash it. It is a proof of concept only. But I could make something real, if there's interest.
Also worth noting that it could easily work on a stream if necessary. It only needs to seek forward.
Neat, I didn't even think of processing the file manually. Your script should be easily convertible to pure Ruby, and it also seems possible to get number of frames from acTL header - single-frame APNG shouldn't get the tag. I'll try to get it together later if no one jumps in first :3
So, here's Ruby script form - https://gist.github.com/Type-kun/f9cc15dce94fc2c48e31. It's meant to be refactored and integrated into danbooru as a module, so no return codes, only textual exceptions and messages for clarity. As a bonus, it checks png file structure and signals if ending block is missing. Gonna reopen the issue. ☆♪, thanks for the idea!