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

Popular posts from this blog

Asterisk AGI Python Script to Dialplan does not work -

python - Read npy file directly from S3 StreamingBody -

kotlin - Out-projected type in generic interface prohibits the use of metod with generic parameter -