Coder Social home page Coder Social logo

Comments (4)

jangko avatar jangko commented on June 2, 2024 1

Thank you for reporting this.
I've investigate it. Turn out it is an incomplete png file and therefore according to the spec it is an invalid input.
But I also tested with some other png decoder and they seem ignoring the incomplete part and continue decoding.
The result is of course an incomplete image or image with blank/random/uninitialized pixels of that skipped chunk.

I think it is a good idea to also implement this so called 'relaxed' parsing mode along with 'strict' parsing mode.
nimBMP and libzip are examples of libs that try to recover as much as possible data from a corrupted input file.

PNG format consist of chunks of loosely coupled data, if the parser can work in recovery mode perhaps using some progressive scanning method, we can increase the robustness of nimPNG.

Technically this is not nimPNG bug, so I will open a new issue and mark it as new feature.

from nimpng.

ThomasTJdev avatar ThomasTJdev commented on June 2, 2024

And this is also present if I:

import base64
import nimPNG

const b = """looong base64"""

writeFile("debug.png",base64.decode(b))
let png = loadPNG("debug.png", LCT_RGBA, 8)

# = > cannot read from stream

from nimpng.

ThomasTJdev avatar ThomasTJdev commented on June 2, 2024

Okay, I had not thought about checking the output image. Using imagemagic convert gives some info on the image created using linux base64. This indicates, that it's my base64-string which is faulty.

$ convert
Expected 8192 bytes; found 7782 bytes

$ pngcheck -7cv debug.png
File: debug.png (393216 bytes)
  chunk IHDR at offset 0x0000c, length 13
    370 x 493 image, 32-bit RGB+alpha, non-interlaced
  chunk sRGB at offset 0x00025, length 1
    rendering intent = perceptual
  chunk eXIf at offset 0x00032, length 68:  illegal (unless recently approved) unknown, public chunk
ERRORS DETECTED in debug.png

from nimpng.

ThomasTJdev avatar ThomasTJdev commented on June 2, 2024

Closed due to my previous comment. It must be my base64 which is malformed.

from nimpng.

Related Issues (20)

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.