When is it OK to upload images of code/data/errors?
– If your answer is never, can we please talk about it?
Don't get me wrong.
I don't endorse uploading code/text in an image instead of uploading the plain text.
But: when may it be appropriate to upload code/text in an image as a complement?
The currently highest-voted FAQ answer on the topic lists 20 reasons why I should not post code (or error/exception messages, log files, configuration files, project files, or anything else that is represented in textual form) as an image.
I will scrutinize every one of those 20 cases.
A command line interface is also a user interface
Before moving on to the list, let me point out that, right below the list, there is a sentence that directly contradicts the call to never upload code or text as an image, at least in some cases.
Images should only be used to illustrate problems that can't be made clear in any other way, such as to provide screenshots of a user interface.
As we all know, a command line interface is also a user interface. Thus, when something in the command line interface other than text needs to be conveyed to the reader (for example, colorization), I argue that this may be a good reason to upload text in an image as a complement. (See this example that I discuss at the end of this post.)
The list of reasons not to upload code/text as an image
Here is the list of cases/reasons, along with my comments.
- Images cannot be interpreted by screen readers, making them completely inaccessible for users with visual impairments.
– That's why I should always remember to provide a description of the image, and why I should never upload an image containing text instead of uploading the plain text.
- Text can be zoomed in and zoomed out at the user's convenience, whereas screenshots typically can't be zoomed in.
– Not true.
In my web browser, I use Ctrl++ to zoom in, and Ctrl+- to zoom out.
Images are zoomed in and out with the rest of the content.
- Code or sample data in images can't be copied and pasted into an editor and compiled in order to reproduce the problem.
– Agreed.
That's why I should never upload an image containing text instead of uploading the plain text.
- Images are large and hard to read on mobile devices, and often cost mobile users valuable data that is limited.
– I'm a Boomer. I've never visited Stack Overflow on a "mobile device".
- Images that are very wide or tall may be scaled improperly, and can cause very squished/small text or an unnecessary amount of scroll.
– Agreed. True for all images?
- Images can be blocked by corporate proxies, and therefore the code isn't available to those readers. This also applies to certain school networks, particularly in the US, as well as entire countries (notably China).
– Agreed.
That's why I should never upload an image containing text instead of uploading the plain text.
- Images can't be searched and therefore aren't useful to future readers.
– Agreed.
That's why I should never upload an image containing text instead of uploading the plain text.
- Images are harder to read than text.
– Agreed.
That's why I should never upload an image containing text instead of uploading the plain text.
- For larger code snippets, you may require multiple images one by one, which may break the continuation, readability & extensibility. However, a very long block of code can easily be placed in a code format.
– Agreed. I think this is one of the few situations where it might be a bad idea to upload an image containing text as a complement to uploading the plain text, even if the image conveys information other than the text itself.
- Posting images of your code is more difficult than copying/pasting the actual code and formatting it.
– Let me, the poster, decide whether I'm willing to put in the needed extra effort.
- You're asking us to volunteer our time for free to solve your problem, and you should make it as easy as possible for us to do so.
– Agreed. That's why I should never upload an image containing text instead of uploading the plain text. In fact, this is a strong reason why I should include an image of the code/text if it adds valuable information.
- Hosted image URLs often become stale and unavailable, breaking future ability to read the post.
– That's why Stack Exchange uses the dedicated i.sstatic.net host, right?
- Images show a limited number of lines of code. For moderately complex questions, you cannot fit all the required code on a single screen, even when you have created the most minimal example possible to reproduce the issue at hand.
– See my comment on "larger code snippets" above.
- Others can't help improve your question by fixing your code formatting.
– Agreed.
That's why I should never upload an image containing text instead of uploading the plain text.
- Others can't see if an error in your code is caused by, say, invisible characters or misuse of Unicode characters that look the same (as in this case).
– Agreed.
That's why I should never upload an image containing text instead of uploading the plain text.
- Images require more bandwidth than text: a simple 200 byte text snippet costs a thousand times less bandwidth than a 200 KB image. Since Stack Overflow serves hundreds of millions of views a day, this increase in bandwidth is significant — every byte and every millisecond count.
– OK. This calls for uploading an image containing text as a complement to uploading the plain text, only if the image conveys information other than the text itself.
- Users with poor network speeds may be unable to load certain images at all, especially as screen and screenshot resolutions increase. Users with very restrictive data plans may even disable images entirely to save their data quota.
– Agreed.
That's why I should never upload an image containing text instead of uploading the plain text.
- Dark theme users may find it more difficult to read text in a white box on an otherwise dark page.
– Agreed. True for all images?
(Images containing text shouldn't necessarily be black text on a white background.)
- Images with transparent backgrounds might be perfectly visible in the light theme but completely unreadable in dark mode, or vice versa.
– Agreed. True for all images?
(You should probably think twice before uploading an image with a transparent background.)
- The data dumps do not include images; any offline uses for the data dump, whether officially supported or not, won't see images at all.
– Agreed. True for all images? (Not just for images that contain text.)
A concrete example
In this answer on how to manually fix a single security issue in Node.js, the original poster explains why they include a screenshot of the previous text output to show colorization highlighting of the modules [they] care about :
Because the colorizing is kind of important, here's a screenshot of that last [text output].
In this case, the inclusion of an image also implicitly conveys a message saying :
Look. I don't just talk about what commands to run. I actually ran them myself.And – if the example in the post had been reproducible – any reader who reproduces the example will get a confirmation that the result looks the same in the command line interface (if reproduced on Windows).
The bottom line
The bottom line is that, in my opinion, it's far too simple-minded to say that images containing code/text should never be allowed on any of the Stack Exchange sites.
There are cases when it makes sense to include such images.