png

package
v1.0.70 Latest Latest
Warning

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

Go to latest
Published: Mar 28, 2026 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Extension       string = ".png" // The PNG file extension
	ExtensionLength int    = 4      // PNG extension length

)

Sizes in bytes

Variables

View Source
var (
	First = ScanMode{
			// contains filtered or unexported fields
	}
	LastVersion = ScanMode{
				// contains filtered or unexported fields
	}
	LastLongest = ScanMode{
				// contains filtered or unexported fields
	}
	DefaultScanMode = First
)

ScanMode values

Functions

This section is empty.

Types

type CharacterCard

type CharacterCard struct {
	*character.Sheet
	// contains filtered or unexported fields
}

CharacterCard decoded chara PNG card

func (*CharacterCard) Encode

func (cc *CharacterCard) Encode() (*RawCard, error)

Encode converts a CharacterCard to a RawCard by encoding the character data as base64

func (*CharacterCard) Height

func (p *CharacterCard) Height() int

Height returns the height in pixels of the PNG

func (*CharacterCard) Image

func (p *CharacterCard) Image() (image.Image, error)

Image FromBytes just the image from the raw context

func (*CharacterCard) ScaleDown

func (p *CharacterCard) ScaleDown(size int) error

ScaleDown Scale down the png image

func (*CharacterCard) Thumbnail

func (p *CharacterCard) Thumbnail(size int) (image.Image, error)

Thumbnail Create a thumbnail from the image of the raw context

func (*CharacterCard) ToRawJson

func (cc *CharacterCard) ToRawJson() (*RawJsonCard, error)

ToRawJson converts a CharacterCard to a RawJsonCard by serializing the Sheet to JSON

func (*CharacterCard) Width

func (p *CharacterCard) Width() int

Width returns the width in pixels of the PNG

type Processor

type Processor interface {
	ScanMode(scanMode ScanMode) Processor
	First() Processor
	LastVersion() Processor
	LastLongest() Processor
	Err() error
	ImageSize() (int, int)
	Get() (*RawCard, error)
	Close() error
}

Processor API for decoding chara PNG cards

func FromBytes

func FromBytes(data []byte) Processor

FromBytes creates a Processor from a byte slice containing PNG image data

func FromFile

func FromFile(path string) Processor

FromFile creates a Processor from a PNG file at the given path

func FromImage

func FromImage(r io.ReadCloser) Processor

FromImage creates a Processor from an io.Reader containing PNG image data

func FromURL

func FromURL(c *reqx.Client, urls ...string) Processor

FromURL creates a Processor by fetching a PNG image from the given URL

type RawCard

type RawCard struct {
	RawCharaData []byte
	Revision     character.Revision
	// contains filtered or unexported fields
}

RawCard encoded chara PNG card

func PlaceholderCharacterCard

func PlaceholderCharacterCard(size int) (*RawCard, error)

PlaceholderCharacterCard returns a placeholder character card of the given size (black PNG image)

func (*RawCard) Decode

func (rc *RawCard) Decode() (*CharacterCard, error)

Decode converts a RawCard to a CharacterCard by decoding the base64 character data

func (*RawCard) Height

func (p *RawCard) Height() int

Height returns the height in pixels of the PNG

func (*RawCard) Image

func (p *RawCard) Image() (image.Image, error)

Image FromBytes just the image from the raw context

func (*RawCard) ScaleDown

func (p *RawCard) ScaleDown(size int) error

ScaleDown Scale down the png image

func (*RawCard) Thumbnail

func (p *RawCard) Thumbnail(size int) (image.Image, error)

Thumbnail Create a thumbnail from the image of the raw context

func (*RawCard) ToBytes

func (rc *RawCard) ToBytes() ([]byte, error)

ToBytes returns the RawCard as a PNG image byte slice

func (*RawCard) ToFile

func (rc *RawCard) ToFile(path string) error

ToFile saves the RawCard as a PNG image file at the specified path

func (*RawCard) ToImage

func (rc *RawCard) ToImage(w io.Writer) error

ToImage writes the RawCard as a PNG image to the provided writer

func (*RawCard) ToRawJson

func (rc *RawCard) ToRawJson() (*RawJsonCard, error)

ToRawJson converts a RawCard to a RawJsonCard by decoding the base64 data

func (*RawCard) Width

func (p *RawCard) Width() int

Width returns the width in pixels of the PNG

type RawJsonCard

type RawJsonCard struct {
	RawJsonData []byte
	Revision    character.Revision
	// contains filtered or unexported fields
}

RawJsonCard encoded chara PNG card with JSON data

func (*RawJsonCard) Height

func (p *RawJsonCard) Height() int

Height returns the height in pixels of the PNG

func (*RawJsonCard) Image

func (p *RawJsonCard) Image() (image.Image, error)

Image FromBytes just the image from the raw context

func (*RawJsonCard) ScaleDown

func (p *RawJsonCard) ScaleDown(size int) error

ScaleDown Scale down the png image

func (*RawJsonCard) Thumbnail

func (p *RawJsonCard) Thumbnail(size int) (image.Image, error)

Thumbnail Create a thumbnail from the image of the raw context

func (*RawJsonCard) ToCharacter

func (rjc *RawJsonCard) ToCharacter() (*CharacterCard, error)

ToCharacter converts a RawJsonCard to a CharacterCard by parsing the JSON data

func (*RawJsonCard) ToRaw

func (rjc *RawJsonCard) ToRaw() *RawCard

ToRaw converts a RawJsonCard to a RawCard by encoding the JSON data as base64

func (*RawJsonCard) Width

func (p *RawJsonCard) Width() int

Width returns the width in pixels of the PNG

type ScanMode

type ScanMode struct {
	// contains filtered or unexported fields
}

ScanMode defines the scan mode for PNG card decoding

Jump to

Keyboard shortcuts

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