0.0.2 • Published 13 years ago

png-guts v0.0.2

Weekly downloads
10
License
-
Repository
github
Last release
13 years ago

Command-line tool

cat foo.png | png-guts --strip-ancillary > foo-normalized.png

Options:

--strip-text            strip {iTXt,tEXt,zTXt} chunks
--strip-ancillary       strip all chunks other than {IHDR,PLTE,IDAT,IEND}

NodeJS library example

{PNG_FILE_HEADER, PNGChunkReader} = require 'png-guts'

inspect_png = (readable_stream) ->
  size = PNG_FILE_HEADER.length
  reader = new PNGChunkReader readable_stream
  reader.on 'chunk', (type, data) ->
    console.log "#{type} chunk: #{data.length} bytes"
    size += data.length
  reader.on 'end', () ->
    console.log "file size: #{size.length} bytes"

What is a PNG?

Every PNG file consists of 89 50 4E 47 0D 0A 1A 0A followed by chunks.

Every chunk is encoded thusly:

These are four critical chunk types:

Further reading: