imageType

package module
Version: v0.0.0-...-4e178dd Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 25, 2017 License: MIT Imports: 8 Imported by: 0

README

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.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrInvalidImage = errors.New("invalid image")
)

Functions

This section is empty.

Types

type ImageInfo

type ImageInfo struct {
	Type     string
	MimeType string
	Width    int
	Height   int
}

ImageInfo ...

func Parse

func Parse(rd io.Reader) (img *ImageInfo, err error)

Parse ...

func ParsePath

func ParsePath(filePath string) (img *ImageInfo, err error)

ParsePath ...

Source Files

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL