Skip to content

Fast Image Type,Width,Height detection for go, up to 16 image formats support.

License

Notifications You must be signed in to change notification settings

phuslu/fastimage

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

18 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

package main

import (
	"fmt"
	"github.com/phuslu/fastimage"
)

var data = []byte("RIFF,-\x00\x00WEBPVP8X\n\x00\x00\x00" +
    "\x10\x00\x00\x00\x8f\x01\x00,\x01\x00VP8X\n\x00\x00\x00\x10\xb2" +
    "\x01\x00\x00WEB\x01\x00VP8X\n\x00\x00\x00\x10\xb2\x01\x00" +
    "\x00WEB\x01\x00VP8X\n\x00\x00\x00\x10\xb2\x01\x00\x00W" +
    "EB\x01\x00VP8X\n\x00\x00\x00\x10\xb2\x01\x00\x00WEB"")

func main() {
	fmt.Printf("%+v\n", fastimage.GetInfo(data))
}

// Output: {Type:webp Width:400 Height:301}

Command Tool

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

About

Fast Image Type,Width,Height detection for go, up to 16 image formats support.

Topics

Resources

License

Stars

Watchers

Forks

Languages