Even if I separate the files with
\004before sending them tostdout...
Good thing you can modify the sending procedure. My solution is as follows:
for f in *.jpg; do echo S; base64 "$f"; echo ""; done | # the above is just an example sending process while read dummy; do sed -u '/^$/q' | base64 -d | identify - done Clarification:
- Single "file block" starts with an expendable line ("S" in this case) that carries no data. If
readcannot find a line, the whole command ends. sedpasses data to decoder until there's an empty line (note: additional empty line doesn't change the output ofbase64 -d).- It's crucial to use unbuffered
sed(-uflag); otherwise onesedcould read too much and eventually discard what it thinks is excessive data; then the nextsed(consequently the nextidentify) wouldn't get all the data it should.
The extra line can carry metadata. CompareHints:
for f in *.jpg; do printf "%s\n" "$f"; base64 "$f"; echo ""; done | # the above is just an example sending process while read fname; do printf "%s " "$fname" sed -u '/^$/q' | base64 -d | identify - | cut -f 2- -d " " done - The extra line can carry metadata instead of "S", like a filename or so (but beware of newlines in names etc.).
- Because
base64produces bigger output than its input, you may want to usegzipon the both sides, especially if your stream travels via the Internet.