项目作者: phuslu

项目描述 :
Fast Image Type,Width,Height detection for go, up to 16 image formats support.
高级语言: Go
项目地址: git://github.com/phuslu/fastimage.git
创建时间: 2020-09-23T14:18:12Z
项目社区:https://github.com/phuslu/fastimage

开源协议:MIT License

下载


fastimage - fast image info for go

godoc release goreport coverage

Features

  • Zero Dependencies - no std/3rd imports
  • High Performance - hand-wringing DFA instead of regex/wildcard expression
  • Widely Format - bmp/bpm/gif/jpeg/mng/pbm/pcx/pgm/png/ppm/psd/ras/tiff/webp/xbm/xpm

Getting Started

try on https://play.golang.org/p/8yHaCknD1Rm

  1. package main
  2. import (
  3. "fmt"
  4. "github.com/phuslu/fastimage"
  5. )
  6. var data = []byte("RIFF,-\x00\x00WEBPVP8X\n\x00\x00\x00" +
  7. "\x10\x00\x00\x00\x8f\x01\x00,\x01\x00VP8X\n\x00\x00\x00\x10\xb2" +
  8. "\x01\x00\x00WEB\x01\x00VP8X\n\x00\x00\x00\x10\xb2\x01\x00" +
  9. "\x00WEB\x01\x00VP8X\n\x00\x00\x00\x10\xb2\x01\x00\x00W" +
  10. "EB\x01\x00VP8X\n\x00\x00\x00\x10\xb2\x01\x00\x00WEB"")
  11. func main() {
  12. fmt.Printf("%+v\n", fastimage.GetInfo(data))
  13. }
  14. // Output: {Type:webp Width:400 Height:301}

Command Tool

  1. $ go get github.com/phuslu/fastimage/cmd/fastimage
  2. $ fastimage banner.png
  3. png image/png 320 50