Skip to content

Commit

Permalink
Update usage
Browse files Browse the repository at this point in the history
  • Loading branch information
mugli committed Jul 26, 2019
1 parent 5fbaafd commit 0fd7d6c
Show file tree
Hide file tree
Showing 3 changed files with 103 additions and 1 deletion.
51 changes: 51 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
# png2escpos

Quickly convert PNG files to ESC/POS format, for printing on Epson thermal point-of-sale printers.

This utility removes transparency from image, makes it grayscale and then encodes in ESC/POS format.

---

## Installation

Download binary from [release tab](https://github.com/mugli/png2escpos/releases).

---

## Usage

```
./png2escpos <filename.png>:
Binary output in ESC/POS format will be written directly to stdout.
You can pipe this output directly into an Epson compatible thermal printer with:
Linux: ./png2escpos <file.png> > /dev/usb/lp0
macOS: ./png2escpos <file.png> | lpr -P NAME_OF_PRINTER
Or, if you have a network printer listening at 192.168.1.100:9100
you can use socat to forward from stdin to network like this:
Linux: ./png2escpos <file.png> > socat STDIN TCP4:192.168.1.100:9100
macOS: ./png2escpos <file.png> | socat STDIN TCP4:192.168.1.100:9100
(you may have to install socat on macOS with brew install socat first)
Other commands:
help, --help, -h:
Shows this message
```

---

## Acknowledgement

[NielsLeenheer/EscPosEncoder](https://github.com/NielsLeenheer/EscPosEncoder) - For the rasterization and ESC/POS encoding in JavaScript.

[twg/png2escpos](https://github.com/twg/png2escpos) - For CLI usage pattern.

---

## License

MIT
53 changes: 52 additions & 1 deletion png2escpos.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@ func main() {
showHelp()
}

if os.Args[1] == "help" || os.Args[1] == "--help" || os.Args[1] == "-h" {
showHelp()
}

imgFile := os.Args[1]
err := escpos.PrintImage(imgFile, os.Stdout)

Expand All @@ -22,5 +26,52 @@ func main() {
}

func showHelp() {
os.Exit(1)
help := `
▄▄▄▄▄▄▄ ▄▄ ▄ ▄▄▄▄▄▄▄
█ ▄▄▄ █ ▄▀▄ █ █ ▄▄▄ █
█ ███ █ █▄▄▀ █ ███ █
█▄▄▄▄▄█ ▄ ▄ ▄ █▄▄▄▄▄█
▄▄▄▄ ▄ ▄▀█ ▄ ▄▄▄ ▄
▀▄█ ▀▀▄▀ ▀▀ █ ▄▄▀█▄▄█
███▄▄▄▄▄█ █▄▀ ▄█ ▀ ▀
▄▄▄▄▄▄▄ ▀▄▄ ▀▄▄█▄▄▀
█ ▄▄▄ █ ▄▀█▀█ ▀ █ ▀
█ ███ █ █▄█▄ █▄▀ ▀
█▄▄▄▄▄█ █▄▄██▄▀█▄ ▄ ▀
------
Usage:
Quickly converts PNG files to ESC/POS format and write to stdout,
for printing on Epson thermal point-of-sale printers.
This utility removes transparency from image, makes it grayscale
and then encodes in ESC/POS format.
./png2escpos <filename.png>:
Binary output in ESC/POS format will be written directly to stdout.
You can pipe this output directly into an Epson compatible thermal printer with:
Linux: ./png2escpos <file.png> > /dev/usb/lp0
macOS: ./png2escpos <file.png> | lpr -P NAME_OF_PRINTER
Or, if you have a network printer listening at 192.168.1.100:9100
you can use socat to forward from stdin to network like this:
Linux: ./png2escpos <file.png> > socat STDIN TCP4:192.168.1.100:9100
macOS: ./png2escpos <file.png> | socat STDIN TCP4:192.168.1.100:9100
(you may have to install socat on macOS with brew install socat first)
Other commands:
help, --help, -h:
Shows this message
`
fmt.Println(help)
os.Exit(0)
}
Binary file added sample.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 0fd7d6c

Please sign in to comment.