https://github.com/simonwaldherr/zplgfa
#Golang package and cli tool for converting to #ZPL (from PNG, JPEG and GIF) for @ZebraTechnology-printers
https://github.com/simonwaldherr/zplgfa
gfa golang grf hacktoberfest-accepted image label labeling-tool zebra zebra-label-printers zebra-printer zpl zpl-programming-language zpl2
Last synced: 4 months ago
JSON representation
#Golang package and cli tool for converting to #ZPL (from PNG, JPEG and GIF) for @ZebraTechnology-printers
- Host: GitHub
- URL: https://github.com/simonwaldherr/zplgfa
- Owner: SimonWaldherr
- License: mit
- Created: 2018-10-19T17:48:16.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2024-08-17T10:25:27.000Z (over 1 year ago)
- Last Synced: 2025-02-14T20:42:38.643Z (12 months ago)
- Topics: gfa, golang, grf, hacktoberfest-accepted, image, label, labeling-tool, zebra, zebra-label-printers, zebra-printer, zpl, zpl-programming-language, zpl2
- Language: Go
- Homepage:
- Size: 156 KB
- Stars: 68
- Watchers: 3
- Forks: 17
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
*since I am currently working exclusively in the home office and no longer have to do with labels professionally (only as a hobby), I can unfortunately no longer work on this project.*
*But if someone would like to provide me a [@Zebra](https://github.com/Zebra) printer, I would be happy to develop it further.*
*Of course, pull requests are still welcome.*
# ZPLGFA Golang Package
*convert pictures to ZPL compatible ^GF-elements*
[](https://godoc.org/github.com/SimonWaldherr/zplgfa)
[](https://coveralls.io/github/SimonWaldherr/zplgfa?branch=master)
[](https://goreportcard.com/report/github.com/SimonWaldherr/zplgfa)
[](https://codebeat.co/projects/github-com-simonwaldherr-zplgfa-master)
[](https://app.fossa.io/projects/git%2Bgithub.com%2FSimonWaldherr%2Fzplgfa?ref=badge_shield)
[](https://raw.githubusercontent.com/SimonWaldherr/zplgfa/master/LICENSE)
The ZPLGFA **Golang** package implements some functions to convert PNG, JPEG and GIF encoded graphic files to ZPL compatible ^GF-elements ([Graphic Fields](https://www.zebra.com/us/en/support-downloads/knowledge-articles/gf-graphic-field-zpl-command.html)).
If you need a ready to use application and don't want to hassle around with source code, take a look at the [ZPLGFA CLI Tool](https://github.com/SimonWaldherr/zplgfa/tree/master/cmd/zplgfa) which is based on this package.
## install
1. [install Golang](https://golang.org/doc/install)
1. `go get simonwaldherr.de/go/zplgfa`
## example
take a look at the [example application](https://github.com/SimonWaldherr/zplgfa/tree/master/cmd/zplgfa)
or at this sample code:
```go
package main
import (
"simonwaldherr.de/go/zplgfa"
"fmt"
"image"
_ "image/gif"
_ "image/jpeg"
_ "image/png"
"log"
"os"
)
func main() {
// open file
file, err := os.Open("label.png")
if err != nil {
log.Printf("Warning: could not open the file: %s\n", err)
return
}
defer file.Close()
// load image head information
config, format, err := image.DecodeConfig(file)
if err != nil {
log.Printf("Warning: image not compatible, format: %s, config: %v, error: %s\n", format, config, err)
}
// reset file pointer to the beginning of the file
file.Seek(0, 0)
// load and decode image
img, _, err := image.Decode(file)
if err != nil {
log.Printf("Warning: could not decode the file, %s\n", err)
return
}
// flatten image
flat := zplgfa.FlattenImage(img)
// convert image to zpl compatible type
gfimg := zplgfa.ConvertToZPL(flat, zplgfa.CompressedASCII)
// output zpl with graphic field data to stdout
fmt.Println(gfimg)
}
```
## label server
If you have dozens of label printers in use and need to fill and print label templates, this tool will help you:
[](https://github.com/SimonWaldherr/ups)
## License
[MIT](https://github.com/SimonWaldherr/zplgfa/blob/master/LICENSE)