imagetype

package
v0.3.2 Latest Latest
Warning

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

Go to latest
Published: Apr 3, 2023 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

Package imagetype provides types and functions for identifying Image document types

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrDataLength is an error for data length
	ErrDataLength = errors.New("error the data is not long enough")
)
View Source
var (
	// ErrImageTypeNotFound is an error that represents an imagetype not being found.
	ErrImageTypeNotFound = errors.New("error imagetype not found")
)

Functions

func IsTiffBigEndian

func IsTiffBigEndian(buf []byte) bool

IsTiffBigEndian checks the buf for the TiffBigEndianSignature

func IsTiffLittleEndian

func IsTiffLittleEndian(buf []byte) bool

IsTiffLittleEndian checks the buf for the Tiff LittleEndian Signature

Types

type ImageType

type ImageType uint8

ImageType is type of Image or Metadata file

ImageUnknown: "application/octet-stream"
ImageJPEG:    "image/jpeg"
ImagePNG:     "image/png"
ImageGIF:     "image/gif"
ImageBMP:     "image/bmp"
ImageWebP:    "image/webp"
ImageHEIF:    "image/heif"
ImageRAW:     "image/raw"
ImageTiff:    "image/tiff"
ImageDNG:     "image/x-adobe-dng"
ImageNEF:     "image/x-nikon-nef"
ImagePanaRAW: "image/x-panasonic-raw"
ImageARW:     "image/x-sony-arw"
ImageCRW:     "image/x-canon-crw"
ImageGPR:     "image/x-gopro-gpr"
ImageCR3:     "image/x-canon-cr3"
ImageCR2:     "image/x-canon-cr2"
ImagePSD:     "image/vnd.adobe.photoshop"
ImageXMP:     "application/rdf+xml"
ImageAVIF:    "image/avif"
ImagePPM:     "image/x-portable-pixmap"
const (
	ImageUnknown ImageType = iota
	ImageJPEG
	ImagePNG
	ImageGIF
	ImageBMP
	ImageWebP
	ImageHEIF
	ImageRAW
	ImageTiff
	ImageDNG
	ImageNEF
	ImagePanaRAW
	ImageARW
	ImageCRW
	ImageGPR
	ImageCR3
	ImageCR2
	ImagePSD
	ImageXMP
	ImageAVIF
	ImagePPM
	ImageJP2K   // JP2K represents the JPEG 2000 image type.
	ImageSVG    // SVG represents the SVG image type.
	ImageMAGICK // MAGICK represents the libmagick compatible genetic image type.
)

Image file types Raw/Compressed/JPEG

func Buf

func Buf(buf []byte) (imageType ImageType, err error)

Buf parses a []byte for image magic numbers that identify the imagetype. If []byte is less than searchHeaderLength returns ImageUnknown and ErrDataLength If imageType was not identified returns ImageUnknown and ErrImageTypeNotFound

func FromString

func FromString(str string) ImageType

FromString returns an ImageType for the given content-type string or common filename extension

func ReadAt

func ReadAt(r io.ReaderAt) (imageType ImageType, err error)

ReadAt reads from the reader at the given offset and returns an imageType based on underlying rules. Returns ImageUnknown and an error if imageType was not identified.

func Scan

func Scan(r io.Reader) (imageType ImageType, err error)

Scan reads from the reader and returns an imageType based on underlying rules. Returns ImageUnknown and ErrImageTypeNotFound if imageType was not identified.

func ScanBuf

func ScanBuf(br *bufio.Reader) (imageType ImageType, err error)

ScanBuf peeks at a bufio.Reader and returns an imageType based on underlying rules. Returns ImageUnknown and ErrImageTypeNotFound if imageType was not identified.

func (*ImageType) DecodeMsg

func (z *ImageType) DecodeMsg(dc *msgp.Reader) (err error)

DecodeMsg implements msgp.Decodable

func (ImageType) EncodeMsg

func (z ImageType) EncodeMsg(en *msgp.Writer) (err error)

EncodeMsg implements msgp.Encodable

func (ImageType) Extension

func (it ImageType) Extension() string

Extension returns the default extension for the Imagetype

func (ImageType) IsUnknown

func (it ImageType) IsUnknown() bool

IsUnknown returns true if the Image Type is unknown

func (ImageType) MarshalMsg

func (z ImageType) MarshalMsg(b []byte) (o []byte, err error)

MarshalMsg implements msgp.Marshaler

func (ImageType) MarshalText

func (it ImageType) MarshalText() (text []byte, err error)

MarshalText implements the TextMarshaler interface that is used by encoding/json

func (ImageType) Msgsize

func (z ImageType) Msgsize() (s int)

Msgsize returns an upper bound estimate of the number of bytes occupied by the serialized message

func (ImageType) String

func (it ImageType) String() string

func (*ImageType) UnmarshalMsg

func (z *ImageType) UnmarshalMsg(bts []byte) (o []byte, err error)

UnmarshalMsg implements msgp.Unmarshaler

func (*ImageType) UnmarshalText

func (it *ImageType) UnmarshalText(text []byte) (err error)

UnmarshalText implements the TextUnmarshaler interface that is used by encoding/json

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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