Skip to content

Instantly share code, notes, and snippets.

@ConorOBrien-Foxx
Created October 19, 2016 02:02
Show Gist options
  • Save ConorOBrien-Foxx/d205143d29765012e8dfcb30ab035be0 to your computer and use it in GitHub Desktop.
Save ConorOBrien-Foxx/d205143d29765012e8dfcb30ab035be0 to your computer and use it in GitHub Desktop.
image to text, rough draft.

run as something like

node conv.js <image> | pta.ijs

don't forget to change the dimensions in pta.ijs.

const PNG = require("png-js");
PNG.decode(process.argv[2], (p) => {
console.log([...p].join(" "));
});
key =: |.' `.-'':_",~^!=;><*\/+c?|rLvzT)s(J7[ti{}nuxlC3fI1oFY]yZ5ewajh2SkPE9Vbp6UdqKGmA4OHXRD8#B0M%N$Wg&Q@'
avg =: +/ % #
input =: 1!:1(3)
NB. CHANGE THE FOLLOWING LINE TO THE DIMENSIONS OF YOUR IMAGE.
NB. TODO: find out how to do this better.
d =: 32 32
echo d$key{~<.(#key)*256%~avg@}:"1 ] _4 ]\ ". input -. CR,LF
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment