Documentation
¶
Overview ¶
Package imagetype provides types and functions for identifying Image document types
Index ¶
- Variables
- func IsTiffBigEndian(buf []byte) bool
- func IsTiffLittleEndian(buf []byte) bool
- type ImageType
- func (z *ImageType) DecodeMsg(dc *msgp.Reader) (err error)
- func (z ImageType) EncodeMsg(en *msgp.Writer) (err error)
- func (it ImageType) Extension() string
- func (it ImageType) IsUnknown() bool
- func (z ImageType) MarshalMsg(b []byte) (o []byte, err error)
- func (it ImageType) MarshalText() (text []byte, err error)
- func (z ImageType) Msgsize() (s int)
- func (it ImageType) String() string
- func (z *ImageType) UnmarshalMsg(bts []byte) (o []byte, err error)
- func (it *ImageType) UnmarshalText(text []byte) (err error)
Constants ¶
This section is empty.
Variables ¶
var ( // ErrDataLength is an error for data length ErrDataLength = errors.New("error the data is not long enough") )
var ( // ErrImageTypeNotFound is an error that represents an imagetype not being found. ErrImageTypeNotFound = errors.New("error imagetype not found") )
Functions ¶
func IsTiffBigEndian ¶
IsTiffBigEndian checks the buf for the TiffBigEndianSignature
func IsTiffLittleEndian ¶
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 ¶
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 ¶
FromString returns an ImageType for the given content-type string or common filename extension
func ReadAt ¶
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 ¶
Scan reads from the reader and returns an imageType based on underlying rules. Returns ImageUnknown and ErrImageTypeNotFound if imageType was not identified.
func ScanBuf ¶
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) Extension ¶ added in v0.1.0
Extension returns the default extension for the Imagetype
func (ImageType) MarshalMsg ¶ added in v0.0.2
MarshalMsg implements msgp.Marshaler
func (ImageType) MarshalText ¶
MarshalText implements the TextMarshaler interface that is used by encoding/json
func (ImageType) Msgsize ¶ added in v0.0.2
Msgsize returns an upper bound estimate of the number of bytes occupied by the serialized message
func (*ImageType) UnmarshalMsg ¶ added in v0.0.2
UnmarshalMsg implements msgp.Unmarshaler
func (*ImageType) UnmarshalText ¶
UnmarshalText implements the TextUnmarshaler interface that is used by encoding/json