-
Notifications
You must be signed in to change notification settings - Fork 11
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
PNG Frame Extract Weirdness #15
Comments
I think this file contains broken frames. Have you successfully extracted all frames within other tools? |
P4 claims to have done it with their own php
https://github.com/p4-team/ctf/blob/master/2016-09-09-asis-final/p1ng/README.md
…On Mon, Feb 18, 2019, 8:55 PM eight ***@***.*** wrote:
I think this file contains broken frames. Have you successfully extracted
all frames within other tools?
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#15 (comment)>, or mute
the thread
<https://github.com/notifications/unsubscribe-auth/AHR34KREeBZz8dQt0c9TUJiM3eQUlrzSks5vO1l5gaJpZM4bB85u>
.
|
The decoding process in your link is not correct. They ignore the image width/height given by the APNG frame. You can change the width/height of each frame manually by using some tools like tweakpng. After fixing each frame's width/height, you should get an identical result. Here is a python version that will divide width/height by 10 when they are too large: import struct
from apng import APNG, make_chunk
im = APNG.open("w.png")
i = 0
first_png = im.frames[0][0]
first_hdr = first_png.chunks[0][1]
for png, ctrl in im.frames:
# fix header
width = png.width
if png.width == 1280:
width = first_png.width
elif png.width >= 1000:
width = png.width // 10
height = png.height
if png.height == 768:
height = first_png.height
elif png.height >= 100:
height = png.height // 10
chunk_data = make_chunk("IHDR", struct.pack("!II", width, height) + first_hdr[16:-4])
png.chunks[0] = ("IHDR", chunk_data)
png.save("{}.png".format(i))
i += 1 |
Been banging my head on writing an apng extraction myself. It somewhat works, but I run into issues with this file. Looks like your method runs into issues too..
The file was manually edited by the author to set the number of frames to 1. The technique of looking at the chunks themselves obviously gets by that. However, many of the images that get pulled out are corrupt.
My knowledge of PNG isn't the greatest, so I'm not sure if they're corrupt due to some process error in extracting or if they started that way... Either way, both of our extraction approaches cause some of the output files to be errored.
The text was updated successfully, but these errors were encountered: