TheYahya / zplgfa

#Golang package and cli tool for converting to #ZPL (from PNG, JPEG and GIF) for @ZebraTechnology-printers

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

ZPLGFA Golang Package

convert pictures to ZPL compatible ^GF-elements

GoDoc Build Status Coverage Status Go Report Card codebeat badge BCH compliance 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

Is it any good?

Yes

License

MIT

About

#Golang package and cli tool for converting to #ZPL (from PNG, JPEG and GIF) for @ZebraTechnology-printers

License:MIT License


Languages

Language:Go 100.0%