Skip to content

mushroomsir/image-type

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

image-type

Build Status Coverage Status License

Installation

go get github.com/mushroomsir/image-type

Support Format

  • jpeg
  • png
  • gif
  • bmp
  • webp
  • webp(lossy)
  • psd
  • ico
  • tiff
  • dds

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

About

Parse image dimension and type

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages