Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

add --strip-ancillary

  • Loading branch information...
commit 567a7ead21516814cdfdf33444522400df179259 1 parent 69d419d
@andrewschaaf authored
Showing with 11 additions and 7 deletions.
  1. +11 −7 png-guts.coffee
View
18 png-guts.coffee
@@ -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
Please sign in to comment.
Something went wrong with that request. Please try again.