imgpro

package module
v0.0.0-...-2bcc667 Latest Latest
Warning

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

Go to latest
Published: Aug 3, 2022 License: MIT Imports: 2 Imported by: 0

README

Imgpro

CircleCI

Imgpro is a multifunctional image information recognition library, supporting a variety of image formats. And it can be run in the browser through WebAssembly(wasm).

Online Demo: imgpro

Usage
Initial
$ go get github.com/echosoar/imgpro
Use in code
import (
  "github.com/echosoar/imgpro"
)

func main() {
  // run by file path
  result := imgpro.Run("./test/imgs/go.png", []string{"size", "type"})
  // you can also run by file binary data
  // result := imgpro.RunBinary(binary, attributes)
  
  if result["size"].Int != 60746 {
    panic("size error")
  }
  
  if result["type"].String != "png" {
    panic("type error")
  }
}
Method
Run

Get image information by local file path

Param Index Param Name Type Examples
0 filePath string "./test/imgs/go.png"
1 attributes []string []string{"size", "type", "rgba", "hue", "qrcode"}
import (
  "github.com/echosoar/imgpro"
)

func main() {
  result := imgpro.Run("./test/imgs/go.png", []string{"size", "type", "rgba", "hue", "qrcode"})
}
RunBinary

Get image information by file binary data

Param Index Param Name Type Examples
0 fileBinary []byte reader.Read(binary)
1 attributes []string []string{"size", "type", "rgba", "hue", "qrcode"}
import (
  "bufio"
  "os"

  "github.com/echosoar/imgpro"
)

func main() {
  fileHandler, err := os.Open(filePath)
	if err != nil {
		panic("open error")
	}
	defer fileHandler.Close()
	fileBytes := make([]byte, size)
	reader := bufio.NewReader(fileHandler)
	_, readErr := reader.Read(fileBytes)
	if readErr != nil {
		panic("file read error")
	}
  result := imgpro.RunBinary(fileBytes, []string{"size", "type", "rgba", "hue", "qrcode"})
}
Features
Features Attribute PNG JPG GIF BMP WebP HEIC AVIF
File Size size
Format Detect type
Width/Height wh
Frames frame
Color data rgba
Color proportion hue
QR Code qrcode
Exif exif
Create Time time
Position(GPS) Info position
Device Info device

© MIT by echosoar

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Run

func Run(filePath string, features []string) img.Result

Run run

func RunBinary

func RunBinary(imgFileBinary []byte, features []string) img.Result

RunBinary run

Types

This section is empty.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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