Class: BloatPNG

Inherits:
Object
  • Object
show all
Defined in:
lib/bloatpng.rb

Class Method Summary collapse

Class Method Details

.bloat(input, output, size = 256) ⇒ Object

“Bloats” a PNG file by adding random data in the form of text elements



8
9
10
11
12
13
14
15
16
# File 'lib/bloatpng.rb', line 8

def self.bloat(input, output, size=256)
  if(size < 20)
    raise NeedsMoreBloatException
  end
  n = size - 32 - (Math.log(size) / Math.log(2)).to_i
  key = SecureRandom.hex(15)
  text = SecureRandom.hex(n)[1..n]
  self.insert_text_element(input, output, key, text)
end