Skip to content

Latest commit

 

History

History
62 lines (49 loc) · 1.6 KB

README.md

File metadata and controls

62 lines (49 loc) · 1.6 KB

image-type

Build Status Coverage Status License

Installation

go get github.com/mushroomsir/image-type

Support

Format Type MimeType Dimension
jpg support support support
png support support support
gif support support support
bmp support support support
webp support support support
ico support support no

Usage

parse image

package main

import (
	"fmt"

	imageType "github.com/mushroomsir/image-type"
)

func main() {
	// imageType.ParseFile(file *os.File)
	// imageType.ParseReader(rd io.Reader)
	// imageType.Parse(bytes []byte)
	res, err := imageType.ParsePath("../testdata/test.jpg")
	if err == nil {
		fmt.Println(res.Type)     // jpg
		fmt.Println(res.MimeType) // image/jpeg
		fmt.Println(res.Width)    // 600
		fmt.Println(res.Height)   // 600
	} else {
		fmt.Println(err)
	}
}

check image

res, _ := imageType.ParsePath("../testdata/test.jpg")
if res != nil {
	fmt.Println("It's image")
}

Licenses

All source code is licensed under the MIT License.