Browse Source

iniciando algoritmo em coffescript

master
Rafael Polo 8 years ago
parent
commit
1e2eed2010
7 changed files with 30 additions and 0 deletions
  1. BIN
      coffeescript/1.out.png
  2. BIN
      coffeescript/2.out.png
  3. BIN
      coffeescript/3.out.png
  4. BIN
      coffeescript/4.out.png
  5. BIN
      coffeescript/5.out.png
  6. BIN
      coffeescript/cypherpunks.pdf.out.png
  7. +30
    -0
      coffeescript/steganos.coffee

BIN
coffeescript/1.out.png View File

Before After
Width: 10  |  Height: 10  |  Size: 346 B

BIN
coffeescript/2.out.png View File

Before After
Width: 9  |  Height: 9  |  Size: 294 B

BIN
coffeescript/3.out.png View File

Before After
Width: 10  |  Height: 10  |  Size: 357 B

BIN
coffeescript/4.out.png View File

Before After
Width: 7  |  Height: 7  |  Size: 195 B

BIN
coffeescript/5.out.png View File

Before After
Width: 148  |  Height: 148  |  Size: 49 KiB

BIN
coffeescript/cypherpunks.pdf.out.png View File

Before After
Width: 2503  |  Height: 2503  |  Size: 4.6 MiB

+ 30
- 0
coffeescript/steganos.coffee View File

@ -0,0 +1,30 @@
fs = require "fs"
PNG = require("pngjs").PNG
encode = (input) ->
fs.readFile input, (err, data) ->
data = new Buffer(data, 'binary')
console.log data
size = data.length
side = Math.ceil (Math.sqrt size)
console.log "#{size} pixels"
console.log "dimension: #{side} x #{side}"
image = new PNG(width: side, height: side)
image.data = data
console.log '--- encoding ---'
image.pack().pipe(fs.createWriteStream("#{input}.out.png"))
decode = (input, output) ->
fs.createReadStream(input).pipe(new PNG()).on "parsed", ->
console.log '--- decoding ---'
result = new Buffer(@data.slice(0, (@height*@width) - 5))
console.log result
console.log result.length
fs.writeFile output, result, (err) -> console.log "Ok!" unless err
#encode('bia.jpg')
#decode('bia.jpg.out.png', 'bia.out.jpg')

Loading…
Cancel
Save