Convert byte array of signed ints to file - Ruby -
i have message server in following format
result = "123,-23,12,...,54,-53"
that message represents array byte of image. how can convert actual image?
i converted result array of ints , tried with:
file.open( 'imagex.png', 'wb' ) |output| splited.each | byte | output.print byte end end
but image not recognizable. missing?
i suspect you'll want try like:
file.write("imagex.png", result.split(',').map(&:to_i).pack('c*'))
i hope helps.
cheers!
wiki
Comments
Post a Comment