After I use the following command,
pngString="$(cat example.png)"
echo -n "$pngString" > tmp.png
I can't open the tmp.png as a PNG file. Maybe some information is lost when I use $pngString
to store the image file.
So the question is: How can I store the complete image information using a variable in bash script?
cat
andecho
and all its ilk are at heart text utilities. Letting them loose unsuspectingly on binary files will have unpredictable results. That's why things likebase64
were invented. – Shadur Dec 29 '13 at 11:06