Wolfram Function Repository
Instant-use add-on functions for the Wolfram Language
Function Repository Resource:
Convert an image to ASCII art
ResourceFunction["ImageASCII"][img] converts img to an ASCII art representation and returns a string. | |
ResourceFunction["ImageASCII"][img,prop] converts img to an ASCII art representation and returns the result as the specified prop. |
| "Grid" | a Grid of characters |
| "Image" | an Image object,including rasterized characters |
| "Text" | a single string (default) |
| FontSize | 12 | font size to use when rasterizing ASCII characters |
| "ProcessingFunction" | Automatic | preprocessing applied to the image |
| RasterSize | Automatic | resize img before processing |
Convert an image into a string:
| In[1]:= |
|
| Out[1]= |
|
Check the output type:
| In[2]:= |
|
| Out[2]= |
|
Convert an image into a structured Grid of copyable characters:
| In[3]:= |
|
| Out[3]= |
|
Check the output type:
| In[4]:= |
|
| Out[4]= |
|
The output contains formatted characters:
| In[5]:= |
|
| Out[19]= |
|
Convert an image into an ASCII art raster:
| In[20]:= |
|
| Out[20]= |
|
Specifying a custom font size for the character rasterization may result in a better recovered output:
| In[21]:= |
|
| Out[21]= |
|
On the other hand, a larger font size might improve the time complexity:
| In[22]:= |
|
| Out[22]= |
|
By default, a combination of image processing operations is performed to preprocess the input image:
| In[23]:= |
|
| Out[23]= |
|
Using a custom preprocessing function affects the output quality:
| In[24]:= |
|
| Out[24]= |
|
By default, the input image dimensions are preserved:
| In[25]:= |
|
| Out[25]= |
|
| In[26]:= |
|
| Out[26]= |
|
Resize the image:
| In[27]:= |
|
| Out[27]= |
|
| In[28]:= |
|
| Out[28]= |
|
Grab an image:
| In[29]:= |
|
Create an ASCII art version of the image:
| In[30]:= |
|
Export the result:
| In[31]:= |
|
| Out[31]= |
|
Use the conversion result as a code comment:
Import a GIF image from the web:
| In[32]:= |
|
| Out[32]= |
|
Generate an ASCII art version for each of the frames:
| In[33]:= |
|
| Out[33]= |
|
Using a new font requires rasterizing a new ASCII character set, which might be slow:
| In[34]:= |
|
| Out[34]= |
|
Using the same font a second time is much faster:
| In[35]:= |
|
| Out[35]= |
|
The final output image size might not exactly match the input image size:
| In[36]:= |
|
| Out[36]= |
|
| In[37]:= |
|
| Out[37]= |
|
Any font size smaller than 4 doesn't produce readable characters when outputting an Image:
| In[38]:= |
|
| Out[38]= |
|
Take a high-resolution image:
| In[39]:= |
|
| In[40]:= |
|
| Out[40]= |
|
| In[41]:= |
|
| Out[41]= |
|
Convert to ASCII art with a very small font size:
| In[42]:= |
|
| Out[42]= |
|
Blend the ASCII version with the original image to get a high quality colored ASCII art raster:
| In[43]:= |
|
| Out[43]= |
|
This work is licensed under a Creative Commons Attribution 4.0 International License