imgfmt

package
v0.76.3 Latest Latest
Warning

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

Go to latest
Published: Dec 14, 2024 License: MPL-2.0 Imports: 4 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

View Source
var All = []Enum{
	Unknown,
	BMP,
	GIF,
	ICO,
	JPEG,
	PNG,
	WBMP,
	WEBP,
}

All possible values.

Functions

func AllReadableExtensions

func AllReadableExtensions() []string

AllReadableExtensions returns all file extensions that map to readable image formats.

func AllWritableExtensions

func AllWritableExtensions() []string

AllWritableExtensions returns all file extensions that map to writable image formats.

func Distill

func Distill(filePathOrURL string) string

Distill a file path or URL string into one that likely has an image we can read, or an empty string.

Types

type Enum

type Enum byte

Enum holds the type of encoding an image was stored with.

const (
	Unknown Enum = iota
	BMP
	GIF
	ICO
	JPEG
	PNG
	WBMP
	WEBP
)

Possible values.

func Extract

func Extract(str string) Enum

Extract the value from a string.

func ForExtension

func ForExtension(ext string) Enum

ForExtension returns the image format for the given file extension.

func ForMimeType

func ForMimeType(mimeType string) Enum

ForMimeType returns the image format for the given mime type.

func ForPath

func ForPath(p string) Enum

ForPath returns the image format for the given file path's extension.

func ForUTI

func ForUTI(uti string) Enum

ForUTI returns the image format for the given Universal Type Identifier.

func (Enum) CanRead

func (e Enum) CanRead() bool

CanRead returns true if the format can be read.

func (Enum) CanWrite

func (e Enum) CanWrite() bool

CanWrite returns true if the format can be written.

func (Enum) EnsureValid

func (e Enum) EnsureValid() Enum

EnsureValid ensures this is of a known value.

func (Enum) Extension

func (e Enum) Extension() string

Extension returns the primary extension for the format. An unknown format will return an empty string.

func (Enum) Extensions

func (e Enum) Extensions() []string

Extensions returns the list of valid file extensions for the format. An unknown format will return nil.

func (Enum) Key

func (e Enum) Key() string

Key returns the key used in serialization.

func (Enum) MarshalText

func (e Enum) MarshalText() (text []byte, err error)

MarshalText implements the encoding.TextMarshaler interface.

func (Enum) MimeType

func (e Enum) MimeType() string

MimeType returns the primary mime type for the format. An unknown format will return an empty string.

func (Enum) MimeTypes

func (e Enum) MimeTypes() []string

MimeTypes returns the list of valid mime types for the format. An unknown format will return nil.

func (Enum) String

func (e Enum) String() string

String implements fmt.Stringer.

func (Enum) UTI

func (e Enum) UTI() string

UTI returns the uniform type identifier for the format. An unknown format will return an empty string.

func (*Enum) UnmarshalText

func (e *Enum) UnmarshalText(text []byte) error

UnmarshalText implements the encoding.TextUnmarshaler interface.

Jump to

Keyboard shortcuts

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