How to store an image file in bash variable?
You are right in that echo
& company don't seem to handle binary that well. I suspect that the null characters break the stream all too early.
You can convert picture information in some ASCII based format. For instance, this is with base64
:
$ pic=`base64 pic.jpeg`
$ echo $pic | base64 --decode > pic2.jpeg
$ diff pic*
$ echo $?
0