Documentation
¶
Index ¶
- Constants
- Variables
- func ChunkTypeToInt(str string) uint32
- func IntToChunkType(i uint32) string
- func NewPhysData(ppm float64) []byte
- type Chunk
- type PNG
- func (p *PNG) Chunks() []Chunk
- func (p *PNG) FilterChunks(chunkType uint32, region Region) (matched []Chunk)
- func (p *PNG) FirstChunkOfType(chunkType uint32, region Region) (Chunk, error)
- func (p *PNG) InsertChunk(chunkType uint32, data []byte, region Region) error
- func (p *PNG) RegionSlice(region Region) []Chunk
- func (p *PNG) UpsertChunk(chunkType uint32, data []byte, region Region) error
- func (p *PNG) Write(w io.Writer) error
- type PNGHeader
- type Region
Constants ¶
const ( TypeCodeIHDR = 1229472850 TypeCodeIDAT = 1229209940 TypeCodeIEND = 1229278788 TypeCodepHYs = 1883789683 )
Variables ¶
var PNGSignature = []byte{137, 80, 78, 71, 13, 10, 26, 10}
Functions ¶
func ChunkTypeToInt ¶
Fast conversion of chunk type string to equivalent uint32.
func IntToChunkType ¶
Fast conversion of type integer to equivalent string of 4 ASCII characters.
func NewPhysData ¶
Returns chunk data for a pHYs (physical dimensions) chunk, given a value for pixels-per-meter.
Types ¶
type Chunk ¶
func ReadChunk ¶ added in v0.1.4
Read a single chunk from `r`, using `hasher` which must be an IEEE CRC-32 instance.
func ReadChunks ¶ added in v0.1.4
Read all chunks from given reader.
func ReadIHDRChunk ¶ added in v0.1.4
Only read the IHDR chunk from the file, and nothing more. Can be beneficial for high-performance metadata checking.
func (Chunk) Properties ¶
Return values of chunk type's property bits.
type PNG ¶
type PNG struct {
// contains filtered or unexported fields
}
A collection of PNG data/metadata chunks and associated useful operations.
func LoadPNG ¶
Read serialized PNG from given reader into regions of chunks to be operated on or queried.
func (*PNG) FilterChunks ¶ added in v0.2.0
Return all chunks which match a given type code within the given region.
func (*PNG) FirstChunkOfType ¶ added in v0.2.0
Return the first chunk matching the given type code within the given region.
func (*PNG) InsertChunk ¶ added in v0.2.0
Insert a chunk of the given type, containing the given data bytes, into the given region.
func (*PNG) RegionSlice ¶
Return the chunk slice corresponding to the given region.
func (*PNG) UpsertChunk ¶ added in v0.2.1
Replaces the data for the first chunk of the given type, or adds as a new chunk if one does not yet exist.
type PNGHeader ¶
type PNGHeader struct {
Width, Height uint32
BitDepth, ColorType uint8
Compression, Filter, Interlace uint8
}
See: https://exiftool.org/TagNames/PNG.html#ImageHeader