Script to generate colorful text messages out of .ppm images for Riot.im
How i use it:
-
Export an image as a .ppm file
-
Run the script and copy the output
$ node matrix-pixelart.js path/to/image.ppm | xclip
-
Run /devtools in Riot.im (matrix client)
-
Enter 'm.room.message' as the event type
-
Paste the output in the event content field
-
Press send and wait a couple of seconds =)
-
Different applications encode ppm files in different ways, this script contains was only tested with files generated by GIMP and imagemagick(commented out). You might need to adjust a couple of variables if your file isn't correctly parsed.
-
Because each pixel (1:1 aspect ratio) gets transformed into a block character (vertical aspect ratio), expect your source images to become deformed. A workaround is to stretch the image out horizontally before exporting.
-
Matrix instances don't usually support very long messages, if you want to send a very tall image it might be a good idea to split it in chunks.
-
Riot.im will wrap long lines, so be careful to keep the width of your input image to a minimum