qrcode

package
v1.3.9 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 30, 2023 License: Apache-2.0 Imports: 12 Imported by: 0

README

一、二维码的生成

package main

import (
    "github.com/daimayun/go/qrcode"
    "image/png"
    "os"
)

// CreateQrCode 创建普通二维码
func CreateQrCode(fileName, url string, width, height int) (err error) {
	qrCode, err := qrcode.CreateQrCode(url, width, height)
	if err != nil {
		return
	}
	file, err := os.Create(fileName)
	if err != nil {
		return
	}
	defer file.Close()
	err = png.Encode(file, qrCode)
	return
}

// CreateContainLogoQrCode 创建带有logo的二维码
func CreateContainLogoQrCode(fileName, url, logoFilePath string, size, logoWidth, logoHeight int) (err error) {
	qrCode, err := qrcode.CreateContainLogoQrCode(url, logoFilePath, size, logoWidth, logoHeight)
	if err != nil {
		return
	}
	file, err := os.Create(fileName)
	if err != nil {
		return
	}
	defer file.Close()
	err = png.Encode(file, qrCode)
	return
}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CreateContainLogoQrCode

func CreateContainLogoQrCode(content, logoFilePathOrLogoRemoteUrl string, size, logoWidth, logoHeight int) (image.Image, error)

CreateContainLogoQrCode 生成带有logo图片的二维码

func CreateQrCode

func CreateQrCode(content string, width, height int) (image barcode.Barcode, err error)

CreateQrCode 创建普通二维码

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL