Documentation ¶
Index ¶
- Variables
- func DumpBytes(data []byte)
- func DumpBytesClause(data []byte)
- func DumpBytesClauseToString(data []byte) (string, error)
- func DumpBytesToString(data []byte) (string, error)
- func NewPngMediaParser() riimage.MediaParser
- type Chunk
- type ChunkDecoder
- type ChunkIHDR
- type ChunkSlice
- func (cs *ChunkSlice) Chunks() []*Chunk
- func (cs *ChunkSlice) ConstructExifBuilder() (*exif.IfdBuilder, error)
- func (cs *ChunkSlice) Exif() (*exif.Ifd, []byte, error)
- func (cs *ChunkSlice) FindExif() (chunk *Chunk, err error)
- func (cs *ChunkSlice) Index() (index map[string][]*Chunk)
- func (cs *ChunkSlice) SetExif(ib *exif.IfdBuilder) error
- func (cs *ChunkSlice) String() string
- func (cs *ChunkSlice) WriteTo(w io.Writer) error
- type PngMediaParser
- func (pmp *PngMediaParser) GetImage(r io.Reader) (img image.Image, err error)
- func (pmp *PngMediaParser) LooksLikeFormat(data []byte) bool
- func (pmp *PngMediaParser) Parse(rs io.ReadSeeker, size int) (riimage.MediaContext, error)
- func (pmp *PngMediaParser) ParseBytes(data []byte) (riimage.MediaContext, error)
- func (pmp *PngMediaParser) ParseFile(filepath string) (riimage.MediaContext, error)
- type PngSplitter
Constants ¶
This section is empty.
Variables ¶
var ( PngSignature = [8]byte{137, 'P', 'N', 'G', '\r', '\n', 26, '\n'} EXifChunkType = "eXIf" IHDRChunkType = "IHDR" )
var ( ErrNotPng = errors.New("not png data") ErrCrcFailure = errors.New("crc failure") )
Functions ¶
func DumpBytesClause ¶
func DumpBytesClause(data []byte)
func DumpBytesClauseToString ¶
func DumpBytesToString ¶
func NewPngMediaParser ¶
func NewPngMediaParser() riimage.MediaParser
NewPngMediaParser returns a new `PngMediaParser`.
Types ¶
type Chunk ¶
Chunk describes a single chunk.
func (*Chunk) CheckCrc32 ¶
func (*Chunk) UpdateCrc32 ¶
func (c *Chunk) UpdateCrc32()
type ChunkDecoder ¶
type ChunkDecoder struct { }
func NewChunkDecoder ¶
func NewChunkDecoder() *ChunkDecoder
func (*ChunkDecoder) Decode ¶
func (cd *ChunkDecoder) Decode(c *Chunk) (decoded interface{}, err error)
type ChunkIHDR ¶
type ChunkSlice ¶
type ChunkSlice struct {
// contains filtered or unexported fields
}
ChunkSlice encapsulates a slice of chunks.
func NewChunkSlice ¶
func NewChunkSlice(chunks []*Chunk) (*ChunkSlice, error)
func NewPngChunkSlice ¶
func NewPngChunkSlice() (*ChunkSlice, error)
func (*ChunkSlice) Chunks ¶
func (cs *ChunkSlice) Chunks() []*Chunk
Chunks exposes the actual slice.
func (*ChunkSlice) ConstructExifBuilder ¶
func (cs *ChunkSlice) ConstructExifBuilder() (*exif.IfdBuilder, error)
ConstructExifBuilder returns an `exif.IfdBuilder` instance (needed for modifying) preloaded with all existing tags.
func (*ChunkSlice) Exif ¶
func (cs *ChunkSlice) Exif() (*exif.Ifd, []byte, error)
Exif returns an `exif.Ifd` instance with the existing tags.
func (*ChunkSlice) FindExif ¶
func (cs *ChunkSlice) FindExif() (chunk *Chunk, err error)
FindExif returns the the segment that hosts the EXIF data.
func (*ChunkSlice) Index ¶
func (cs *ChunkSlice) Index() (index map[string][]*Chunk)
Index returns a map of chunk types to chunk slices, grouping all like chunks.
func (*ChunkSlice) SetExif ¶
func (cs *ChunkSlice) SetExif(ib *exif.IfdBuilder) error
SetExif encodes and sets EXIF data into this segment.
func (*ChunkSlice) String ¶
func (cs *ChunkSlice) String() string
type PngMediaParser ¶
type PngMediaParser struct { }
PngMediaParser knows how to parse a PNG stream.
func (*PngMediaParser) LooksLikeFormat ¶
func (pmp *PngMediaParser) LooksLikeFormat(data []byte) bool
LooksLikeFormat returns a boolean indicating whether the stream looks like a PNG image.
func (*PngMediaParser) Parse ¶
func (pmp *PngMediaParser) Parse( rs io.ReadSeeker, size int, ) (riimage.MediaContext, error)
Parse parses a PNG stream given a `io.ReadSeeker`.
func (*PngMediaParser) ParseBytes ¶
func (pmp *PngMediaParser) ParseBytes(data []byte) (riimage.MediaContext, error)
ParseBytes parses a PNG stream given a byte-slice.
func (*PngMediaParser) ParseFile ¶
func (pmp *PngMediaParser) ParseFile(filepath string) (riimage.MediaContext, error)
ParseFile parses a PNG stream given a file-path.
type PngSplitter ¶
type PngSplitter struct {
// contains filtered or unexported fields
}
PngSplitter hosts the princpal `Split()` method uses by `bufio.Scanner`.
func NewPngSplitter ¶
func NewPngSplitter() *PngSplitter
func (*PngSplitter) Chunks ¶
func (ps *PngSplitter) Chunks() (*ChunkSlice, error)
func (*PngSplitter) CrcErrors ¶
func (ps *PngSplitter) CrcErrors() []string
func (*PngSplitter) DoCheckCrc ¶
func (ps *PngSplitter) DoCheckCrc(doCheck bool)