+// Try to embed an image in the display stream.
+// out = the StrBuf to which we are writing the display stream
+// url = the URL of the image (warning: it might be a data: URL)
+// display_protocol = currently only H2A_SIXEL is supported
+void h2a_embed_image(StrBuf *out, char *url, int display_protocol) {
+
+ char buf[4096];
+ snprintf(buf, sizeof(buf), "curl -s '%s' | img2sixel -", url);
+
+ FILE *cmd = popen(buf, "r");
+ if (!cmd) {
+ return;
+ }
+
+ size_t bytes;
+ while (bytes = fread(buf, 1, sizeof(buf), cmd), bytes>0) {
+ StrBufAppendBufPlain(out, buf, bytes, 0);
+ }
+ pclose(cmd);
+}
+