git.sr.ht/~pingoo/stdx@v0.0.0-20240218134121-094174641f6e/barcode/README.md (about)

     1  [![Join the chat at https://gitter.im/golang-barcode/Lobby](https://badges.gitter.im/golang-barcode/Lobby.svg)](https://gitter.im/golang-barcode/Lobby?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
     2  
     3  ## Introduction ##
     4  
     5  This is a package for GO which can be used to create different types of barcodes.
     6  
     7  ## Supported Barcode Types ##
     8  * 2 of 5
     9  * Aztec Code
    10  * Codabar
    11  * Code 128
    12  * Code 39
    13  * Code 93
    14  * Datamatrix
    15  * EAN 13
    16  * EAN 8
    17  * PDF 417
    18  * QR Code
    19  
    20  ## Example ##
    21  
    22  This is a simple example on how to create a QR-Code and write it to a png-file
    23  ```go
    24  package main
    25  
    26  import (
    27  	"image/png"
    28  	"os"
    29  
    30  	"git.sr.ht/~pingoo/stdx/barcode"
    31  	"git.sr.ht/~pingoo/stdx/barcode/qr"
    32  )
    33  
    34  func main() {
    35  	// Create the barcode
    36  	qrCode, _ := qr.Encode("Hello World", qr.M, qr.Auto)
    37  
    38  	// Scale the barcode to 200x200 pixels
    39  	qrCode, _ = barcode.Scale(qrCode, 200, 200)
    40  
    41  	// create the output file
    42  	file, _ := os.Create("qrcode.png")
    43  	defer file.Close()
    44  
    45  	// encode the barcode as png
    46  	png.Encode(file, qrCode)
    47  }
    48  ```
    49  
    50  ## Documentation ##
    51  See [GoDoc](https://godoc.org/git.sr.ht/~pingoo/stdx/barcode)
    52  
    53  To create a barcode use the Encode function from one of the subpackages.