Skip to content

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

License

Notifications You must be signed in to change notification settings

echosoar/imgpro

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

About

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

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published