0

I need to transfer a generated 1920x1080 image out of a Node pipeline that has no connectivity to either the internet or me, with the only controllable output being plaintext logs

So in order to retrieve that image, I need some way to transfer that data through a log file, which is tricky given the image is around 45KB with .jpeg compression

Converting the image to a base64 data URI works perfectly, as I can copy it from the logs and see the image in my browser, but the size of the URI is unwieldly at 40k+ characters

Is there a more compact or efficient way of doing this?

Jayleaf
  • 31
  • 1
  • 9
  • For what it's worth you're asking a question that covers an entire field of computer science study. It's a tough question to answer, as it's hard to give meaningful advice without a bunch of extra information from the project you're working on. Just remember that any answer here might not actually be the best specifically for your case since it's quite broad. – Qix - MONICA WAS MISTREATED Oct 08 '21 at 04:13
  • If your image is a screen-capture of somewhat *"blocky"* computer graphics, rather than a hi-res digital photograph, it might respond quite well to being resized to 1/2 or 1/4 of its width and height. – Mark Setchell Oct 08 '21 at 06:49

1 Answers1

0

This link gives insight: Binary To text Encoding

Base85 Base85/ASCII85 is probably most promising but offers no more than 5% improvement. Is ~42KB less unwieldy than 45KB? How long will the solution live, how "shareable" must the output be and must image quality be preserved?

If image quality for your purpose is not all that important, you may get better mileage out of fiddling with encoding options (JPEG is a lossy method of encoding so you could save significant space at the cost of letting the images get more grainy although at 45KB they probably already are (?)).

You may want to get rid of mention of URIs in your question. You're interested in Base64 as an encoding method (for which 64 common text characters are used as digits... like decimal uses 10, hexadecimal 16 and Base85 85 etc). Base64 is just a ubiquitous "standard" (actually a family of several standards - see Base64 Variants).

AlanK
  • 1,827
  • 13
  • 16
  • Image quality isn't important as long as it's readable, as the output is just used for debugging. But it must be easily shareable with minimal steps to extract the image, which is where base64 data URIs really shine. The 45KB is with .jpeg compression enabled at 70% quality, uncompressed is 68KB, is there more that could be done to reduce it? And good suggestion, I'll change the title to be more specific – Jayleaf Oct 08 '21 at 04:06
  • Base85 offers small improvement and won't travel very well. At 45KB I suspect you've already sacrificed image quality but reencoding images for debug purposes (perhaps using only 8 color bits) may be more worthwhile. Or you can do both (or neither - remember the law of diminishing returns;-). – AlanK Oct 08 '21 at 04:15