Skip to content

Commit

Permalink
add --strip-ancillary
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewschaaf committed Aug 5, 2012
1 parent 69d419d commit 567a7ea
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions png-guts.coffee
Expand Up @@ -9,17 +9,21 @@ main = () ->

argv = require('optimist').argv

# --strip-text
ignoreBlocks = {}
if argv['strip-text']
for k in ['iTXt', 'tEXt', 'zTXt']
ignoreBlocks[k] = true
typeWhitelist = null
typeBlacklist = {}

if argv['strip-text']?
typeBlacklist = {'iTXt', 'tEXt', 'zTXt'}

if argv['strip-ancillary']?
typeWhitelist = {'IHDR', 'PLTE', 'IDAT', 'IEND'}

process.stdout.write PNG_FILE_HEADER
reader = new PNGChunkReader process.openStdin()
reader.on 'chunk', (type, raw) ->
if not ignoreBlocks[type]
process.stdout.write raw
return if typeWhitelist and not (typeWhitelist[type]?)
return if typeBlacklist[type]?
process.stdout.write raw


class PNGChunkReader extends EventEmitter
Expand Down

0 comments on commit 567a7ea

Please sign in to comment.