Giter Club home page Giter Club logo

Comments (3)

eight04 avatar eight04 commented on June 19, 2024

I think this file contains broken frames. Have you successfully extracted all frames within other tools?

from pyapng.

bannsec avatar bannsec commented on June 19, 2024

from pyapng.

eight04 avatar eight04 commented on June 19, 2024

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

from pyapng.

Related Issues (11)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.