
Product
Reachability for Ruby Now in Beta
Reachability analysis for Ruby is now in beta, helping teams identify which vulnerabilities are truly exploitable in their applications.
png-to-json
Advanced tools
Tiny library to parse Png files (or uint8Arrays containing Png data structures) into JSON human readable Objects. It extracts all the data from the IHDR chunk, and creates an array of chunks with it's relative byte blocks.
Accepts different data sources :
Usage example (Node):
let fileData = fs.readFileSync('./test.png');
let pngJSON = pngToJSON(fileData);
console.log(pngJSON);
pngToJSON( HTMLInputElement, callback );
HTMLInputElement: Reference to the DOM File Input Elementcallback: Function to receive the results of the conversion. It accepts two arguments : JSON PNG Object and Source File Info.pngToJSON( FileReference, callback )
FileReference: Reference to the file returned from the File Input Element ( InputElement.files[x] )callback: Function to receive the results of the conversion. It accepts two arguments : JSON PNG Object and Source File Info.pngToJSON( Uint8ArrayData )
Uint8ArrayData:Uint8Array typed Array containing the png file dataReturns : JSON representation of the png file contents.
The returned JSON Object i strutured in thw following way (most keys are self explanatory)
pngJSON{
bitDepth: Integer,
chunks: Integer, // total count
colorType: Integer,
colorTypeString: String, // string representation
compressionMethod: Integer,
data: Uint8Array[...], // png file data
filterMethod: Integer,
height: Integer, // image height
interlaceMethod: Integer,
signature: Uint8Array[...], // firat 8 bytes
width: Integer, // image width
chunk: [
[0] : {
data: Uint8Array[...], // chunk data block
raw : Uint8Array[...], // full chunk block
id: Integer,
isCritical: Boolean,
isPublic: Boolean,
chunkLength: Integer, // chunk length
dataLength: Integer, // chunk data length
offset: Integer, // chunk start offset
type: String, // chunk type
},
[1] : {...},
[2] : {...},
(...)
]
}
Note : The resulting <pngJSON>.chunk[x].data byteArrays, do not contain the the full chunk data. The bytes corresponding to the length block , type block, and CRC block, are stripped from it. It only contains the data block from each chunk.
CHUNK BYTE STRUCTURE :
<------------------------ chunk length -------------------------->
Chunk Offset Chunk Offset+8
├──────────────────┬───────────┼──────────────────────┬──────────┐
│ *DataLength (4b) │ Type (4b) │ Data (*DataLength b) │ CRC (4b) │
└──────────────────┴───────────┴──────────────────────┴──────────┘
<--------- stripped -----------> <-stripped->
Use <pngJSON>.chunk[x].raw instead, to get all the chunk data.
In browser enviroment you can include this library using the jsdelivr CDN ( window.pngToJSON() is created autmatically ) ...
<script src='https://cdn.jsdelivr.net/gh/colxi/png-to-json@latest/src/png-to-json.min.js'></script>
If you are in the NodeJs enviroment, can install the package via:
$ npm install png-to-json --save
Git repository available too :
$ git clone https://github.com/colxi/png-to-json.git
The package can be imported using ES6 import in Browser
import '<libraryPath>/src/png-to-json.js';
// window.pngToJSON() is created autmatically
GPL 3
FAQs
Parse PNG files into JSON human readable structures
We found that png-to-json demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Product
Reachability analysis for Ruby is now in beta, helping teams identify which vulnerabilities are truly exploitable in their applications.

Research
/Security News
Malicious npm packages use Adspect cloaking and fake CAPTCHAs to fingerprint visitors and redirect victims to crypto-themed scam sites.

Security News
Recent coverage mislabels the latest TEA protocol spam as a worm. Here’s what’s actually happening.