Go to file
Simon Waldherr c0d018ffa9
Merge pull request #6 from pic4xiu/master
Program crashes when processing certain maliciously crafted images
2023-06-17 22:20:03 +02:00
cmd/zplgfa fix error handling 2019-04-28 16:35:16 +02:00
tests add more tests 2018-11-06 17:09:56 +01:00
.bettercodehub.yml add more tests 2018-11-06 17:09:56 +01:00
.gitignore add more special commands 2018-11-06 17:18:12 +01:00
.travis.yml travis 2018-10-19 22:45:56 +02:00
LICENSE init 2018-10-19 19:52:47 +02:00
README.md Update README.md 2023-04-18 09:57:17 +02:00
example_test.go add another example 2018-11-04 16:52:42 +01:00
zplgfa.go Update zplgfa.go 2023-06-17 14:37:13 +08:00
zplgfa_test.go add more tests 2018-11-06 17:09:56 +01:00

README.md

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 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

GoDoc Coverage Status Go Report Card codebeat badge FOSSA Status license

The ZPLGFA Golang package implements some functions to convert PNG, JPEG and GIF encoded graphic files to ZPL compatible ^GF-elements (Graphic Fields).

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 which is based on this package.

install

  1. install Golang
  2. go get simonwaldherr.de/go/zplgfa

example

take a look at the example application
or at this sample code:

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:

SimonWaldherr/ups - GitHub

License

MIT