Comments (4)
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.
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.
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.
Closed due to my previous comment. It must be my base64 which is malformed.
from nimpng.
Related Issues (20)
- Throw exceptions on errors instead of writing to stdout HOT 12
- Tests fail when using --gc:arc HOT 3
- This hash look up in calculateColorProfile is the slowest part of saving an image. HOT 2
- compiletime decoder HOT 2
- New API βΒ can't savePNG32 with a seq[uint8] HOT 2
- Improve chunk parser flexibility when decoding incomplete input data.
- savePNG doesn't work for arrays
- Allow parsing into different data types HOT 1
- nim 1.6.0 savePNG results in too nested template instantiation HOT 4
- How to remove all unnecessary data HOT 8
- Enable user to configure compression library settings
- Need better documentation for encoder settings
- Warning: conversion to enum with holes is unsafe: PNGColorType(typ`gensym14) [HoleEnumConv]
- Doesn't compile on Nim devel due to `shallowCopy` being removed from the language.
- `decodePNG` colorType unexpected HOT 3
- savePNGImpl maybe have bug? HOT 3
- Doesn't work by default on Nim v2.0.0 HOT 2
- nimPNG relies on bugs of `newString` to work
- Move tests to another repo HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
π Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google β€οΈ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from nimpng.