Code to image
📷 Screenshot settings
Preview (the exported image is consistent with what is shown here)
💡 Instructions for use
- Paste the code first and then click "Generate Preview": the preview area displays the exported content. Make sure the layout and color matching are correct before downloading the image.
- The dark theme is suitable for chat tools and presentations, while the light theme is suitable for printing and formal documents; the look and feel will be clearer when the background color of the card is opposite to the storage environment.
- Line numbers are convenient for indicating positions in discussions, but they take up horizontal space; it is recommended to turn them off when the code is deeply indented or the screen is narrow.
- What is exported is a PNG with an opaque background, and the file name has a timestamp; it is easy to distinguish the order when the same batch of content is exported multiple times.
- If the code line is too long, the image will obviously become wider. Before pasting, you can manually fold the long line into two lines, or adjust the font size appropriately.
- The code is only rendered and exported within the browser and is not uploaded or saved; sensitive code can also be handled with confidence.
Converting code to images solves the problem of "deformation when sent": indentations and blank lines are rendered as they are, and what the reader sees is the original layout.
Why does text paste become deformed?
Instant messaging tools and some document editors will automatically process text: consecutive spaces are compressed into one, overly long lines are folded to the next line, straight quotes are replaced with Chinese punctuation, and tabs are converted into spaces of unequal width. These treatments are not wrong in isolation, but for the code, they are enough to mess up the indentation level and make it impossible to run after pasting it back. Converting it to a picture can fix the layout and avoid these automatic processes.
When should you still text?
- The other party needs to run or submit directly: please also provide text or code repository link.
- Need to search and compare: pictures cannot be searched, text is more suitable.
- Modifications that require collaboration between multiple people: Use code review tools instead of screenshots.
The key to converting code into images is fixed-width fonts and retaining indents: fixed-width fonts align each column, and indentation retains the hierarchical structure of the code. If the font is not monospaced, the indentation will be messed up, and readers will notice it awkwardly at a glance.
For long lines, it is recommended to manually wrap the lines or adjust the canvas width first, so as not to let the code be automatically truncated. The truncated fragment looks complete, but actually half a line is missing, which can easily cause misunderstanding when quoted in the document.
If the code contains tab characters, it is recommended to convert them into spaces before generating them to avoid inconsistent indent widths in different editors.
Pictures are used for explanation. If you need the other party to actually use it, please attach additional text or a warehouse link.
📖 Glossary
- Code screenshot
- Rendering code into images is more conducive to maintaining indentation and formatting than posting text directly, and is also easier to read in chat tools.
- Theme color matching
- The background and text color scheme of the code card. Dark themes are more eye-catching in chat tools and slideshows, while light themes are more suitable for printing and documents.
- monospaced font
- A font with the same width for each character. Code indentation and alignment depend on it to be neat. You should always choose a fixed-width font when exporting.
- Line number
- Displaying a serial number to the left of each line of code makes it easier to indicate the specific location in the discussion, but it also takes up horizontal space.
- syntax highlighting
- Keywords, strings, and comments are colored according to language rules. This tool provides monochrome rendering to avoid color scheme inconsistency with the editor.
- Vector and bitmap export
- The vector format can be enlarged without distortion and is suitable for printing; the bitmap format has better compatibility and is suitable for pasting directly into the chat window.
- Clarity multiple
- When exporting, the pixels are enlarged by an integer multiple, so that the picture remains sharp when viewed on a high-resolution screen or zoomed in.
- watermark
- The additional text mark at the bottom of the card can be used to mark the source, version or author to avoid losing the source of the screenshot if it is reprinted.
- Leave horizontal space
- Padding around the card. If the white space is too small, the code border will appear crowded, and if it is too large, the image area will be wasted.
- Automatic line wrapping
- Control whether lines of code that are too long are wrapped. Not breaking lines will make the picture wider, but breaking lines may affect the readability of the code.
🔗 All keywords and tutorials
❓ FAQ
- Will the indentation be changed??
- No. Render as a fixed-width font, with spaces and tabs preserved.
- Will Chinese comments be garbled??
- No. Chinese characters and symbols are rendered normally according to the native fonts, and the exported images are equally clear.