a nodejs script that allows you to print images to a phomemo printer.
Tested with phomemo M02s.
printer-smol.mov
For MacOS: You must enable Bluetooth permissions for the terminal on which this runs
This is done by going to System Settings -> Privacy & Security -> Bluetooth, and then adding the terminal program (e.g. iTerm) to allow Bluetooth connections.
This isn't listed on npm (yet?) so you need to clone and build locally to run, e.g.
$ git clone git@github.com:vrk/cli-phomemo-printer.git
$ npm install
$ node index.js
If you run it without command-line arguments, you'll print out a burger sticker.
Options:
-f, --file <path> path for image to print (default: "./burger.png")
-s, --scale <size> percent scale at which the image should print (1-100+) (default: 100)
-h, --help display help for command
- If you're not using the Phomemo M02S: You will need to edit
index.js
to changeBYTES_PER_LINE
to match your paper. IDK what's the math for this, I just used guess & check to figure it out lol. - If you're using smaller receipt paper: The Phomemo M02S comes with 3 sizes of paper, 53mm (default), 25mm, 15mm. If you're using anything other than 53mm, you're going to have to scale the image using the
-s
flag, e.g.-s 50
for 25mm paper. - Known issue: I've found that the dithering library I'm using doesn't work well on certain black & white images. I'll swap it out later...
This code was cobbled together by reading the very helpful breadcrumbs left by:
- vivier/phomemo-tools: lifesaver for having the protocol documented & providing the general algorithm
- Phomemo Thermal Printing On MacOS: gave me faith that this was even possible!