imgsz

package module
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Jan 8, 2022 License: GPL-3.0 Imports: 11 Imported by: 47

README

imgsz

Image size analyzer for jpg/png/gif/webp

Usage

// DecodeSize decodes the dimensions of an image that has
// been encoded in a registered format. The string returned is the format name
// used during format registration. Format registration is typically done by
// an init function in the codec-specific package.
func DecodeSize(r io.Reader) (Size, string, error)

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrFormat = errors.New("image: unknown format")

ErrFormat indicates that decoding encountered an unknown format.

Functions

func NewListReader

func NewListReader(chunkLen uint32, chunkData io.Reader) (listType FourCC, data *Reader, err error)

NewListReader returns a LIST chunk's list type, such as "movi" or "wavl", and its chunks as a *Reader.

func NewReader

func NewReader(r io.Reader) (formType FourCC, data *Reader, err error)

NewReader returns the RIFF stream's form type, such as "AVI " or "WAVE", and its chunks as a *Reader.

func RegisterFormat

func RegisterFormat(name, magic string, decodeSize func(io.Reader) (Size, error))

RegisterFormat registers an image format for use by Decode. Name is the name of the format, like "jpeg" or "png". Magic is the magic prefix that identifies the format's encoding. The magic string can contain "?" wildcards that each match any one byte. Decode is the function that decodes the encoded image. DecodeSize is the function that decodes just its configuration.

Types

type FormatError

type FormatError string

A FormatError reports that the input is not a valid JPEG.

func (FormatError) Error

func (e FormatError) Error() string

type FourCC

type FourCC [4]byte

FourCC is a four character code.

type Reader

type Reader struct {
	// contains filtered or unexported fields
}

Reader reads chunks from an underlying io.Reader.

func (*Reader) Next

func (z *Reader) Next() (chunkID FourCC, chunkLen uint32, chunkData io.Reader, err error)

Next returns the next chunk's ID, length and data. It returns io.EOF if there are no more chunks. The io.Reader returned becomes stale after the next Next call, and should no longer be used.

It is valid to call Next even if all of the previous chunk's data has not been read.

type Size

type Size struct {
	Width, Height int
}

func DecodeSize

func DecodeSize(r io.Reader) (Size, string, error)

DecodeSize decodes the dimensions of an image that has been encoded in a registered format. The string returned is the format name used during format registration. Format registration is typically done by an init function in the codec-specific package.

type UnsupportedError

type UnsupportedError string

An UnsupportedError reports that the input uses a valid but unimplemented JPEG feature.

func (UnsupportedError) Error

func (e UnsupportedError) Error() string

Jump to

Keyboard shortcuts

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