How to Convert a Base64 Image to ASCII Art
Provide a non-empty base64-encoded image string, choose an output width and optional brightness inversion, and convert it to grayscale ASCII art. A successful response includes the text, requested width, computed height, and line count.
Purpose and input format
Image to ASCII turns supplied base64-encoded image data into grayscale ASCII art text. This can help when you need a text representation for a terminal, plain-text note, code comment, or another place where an image cannot be displayed directly.
The conversion works with adjustable output width and optional brightness inversion. After the image is opened, it is converted to grayscale and resized to the requested width. Its original aspect ratio influences the resulting height, with a vertical adjustment applied before the height is reduced to an integer. Grayscale brightness is then represented by characters from a fixed ten-character ramp, and each generated row ends with a newline.
Conversion settings and procedure
-
Prepare the image as a base64-encoded string. The documented input is image data in string form, so do not substitute a file path, direct image URL, or arbitrary binary object.
-
Enter that string in the image data field. Although the input is optional in the contract, leaving it empty causes processing to fail, so provide a non-empty value before starting the conversion.
-
Set the output width when you want to change the default. If you leave the setting unchanged, the width defaults to 80. A smaller width produces a more compact text block, while a larger width can retain more visual detail; the available behavior does not establish a supported width range.
-
Decide whether to enable brightness inversion. The default is false. Enable it when you want the character ramp reversed before brightness values are mapped to characters.
-
Start the conversion and inspect the returned ASCII text. Successful processing also returns the requested width, a computed height, and a line count derived from the number of newline characters in the generated text.
-
If processing fails, review the supplied string first and confirm that it represents readable image data. Failures can occur while the data is decoded or opened, during grayscale conversion or resizing, or while the text is being generated.
Reading dimensions and handling failures
Treat the returned ASCII as a row-based approximation of the source image rather than a color reproduction. The characters communicate grayscale brightness, so visual detail depends on the resized dimensions and on how the text is displayed.
Changing the width changes the amount of horizontal detail and also affects the computed height because the image is resized before character mapping. The height calculation uses the source aspect ratio, applies a 0.55 vertical adjustment, and truncates the result to an integer. The reported line count comes from newline characters, which provides a row-oriented measure of the generated text.
Inversion does not add color information or change the source image; it reverses the character ramp used for the grayscale mapping. If the output is unsuccessful, the returned failure indicates that some processing stage could not complete. Checking the encoding and readability of the image data is a more useful first response than changing the display options.
Worked example
A user has a base64-encoded image and wants a compact text version for a plain-text note.
Paste the prepared base64 string, leave the width at its default, keep inversion off, and start the conversion.
The successful response contains generated ASCII text plus the requested width, a computed height, and a line count derived from newline characters.
Limitations
- This guide covers image data supplied as a base64-encoded string; direct URLs, file paths, and arbitrary binary objects are not documented inputs.
- Unreadable or malformed image data can fail during decoding, opening, grayscale conversion, resizing, or ASCII generation.
Common errors
- Cause: the field contains no data or a value that cannot be decoded and opened as an image. Corrective action: replace it with a non-empty base64-encoded image string and run the conversion again.
FAQ
Can I enter an image URL instead of base64 image data?
The documented input is a base64-encoded image string. A direct image URL, file path, or arbitrary binary object is outside the documented input format.
What width does the conversion use by default?
When no other width is supplied, the conversion uses a default width of 80. The successful response also reports the requested width and the computed height.
What does brightness inversion change?
With inversion enabled, grayscale values are mapped through the reversed character ramp. Leaving the option disabled preserves the default character order.