images

package
v0.45.0 Latest Latest
Warning

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

Go to latest
Published: Dec 24, 2025 License: GPL-3.0 Imports: 27 Imported by: 0

Documentation

Index

Constants

View Source
const SERIALIZE_VERSION = 1
View Source
const TempTemplate = "kitty-tty-graphics-protocol-*"

Variables

View Source
var DecodableImageTypes = map[string]bool{
	"image/jpeg": true, "image/png": true, "image/bmp": true, "image/tiff": true, "image/webp": true, "image/gif": true,
	"image/x-portable-anymap":       true,
	"image/x-portable-bitmap":       true,
	"image/x-portable-graymap":      true,
	"image/x-portable-pixmap":       true,
	"image/x-portable-arbitrarymap": true,
}
View Source
var EncodableImageTypes = map[string]bool{
	"image/jpeg": true, "image/png": true, "image/bmp": true, "image/tiff": true, "image/gif": true,
}
View Source
var NumberToDiacritic = [297]rune{}/* 297 elements not displayed */

Functions

func ConvertEntryPoint

func ConvertEntryPoint(root *cli.Command)

func CreateTemp

func CreateTemp() (*os.File, error)

func CreateTempInRAM

func CreateTempInRAM() (*os.File, error)

func Encode

func Encode(output io.Writer, img image.Image, format_mime string) (err error)

func FitImage

func FitImage(width, height, pwidth, pheight int) (final_width int, final_height int)

func MakeTempDir

func MakeTempDir(template string) (ans string, err error)

func NewNRGBAWithContiguousRGBAPixels added in v0.44.0

func NewNRGBAWithContiguousRGBAPixels(p []byte, left, top, width, height int) (*image.NRGBA, error)

Types

type Context

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

func (*Context) EffectiveNumberOfThreads added in v0.42.2

func (self *Context) EffectiveNumberOfThreads() int

func (*Context) NumberOfThreads

func (self *Context) NumberOfThreads() int

func (*Context) Paste

func (self *Context) Paste(background image.Image, img image.Image, pos image.Point, opaque_bg *imaging.NRGBColor)

Paste pastes the img image to the background image at the specified position. Optionally composing onto the specified opaque color.

func (*Context) PasteCenter

func (self *Context) PasteCenter(background image.Image, img image.Image, opaque_bg *imaging.NRGBColor)

PasteCenter pastes the img image to the center of the background image. Optionally composing onto the specified opaque color.

func (*Context) SafeParallel added in v0.44.0

func (self *Context) SafeParallel(start, stop int, fn func(<-chan int)) (err error)

parallel processes the data in separate goroutines. If any of them panics, returns an error. Note that if multiple goroutines panic, only one error is returned.

func (*Context) SetNumberOfThreads

func (self *Context) SetNumberOfThreads(n int)

type ImageData

type ImageData struct {
	Width, Height    int
	Format_uppercase string
	Frames           []*ImageFrame
}

func ImageFromSerialized added in v0.44.0

func ImageFromSerialized(m SerializableImageMetadata, data [][]byte) (*ImageData, error)

func NewImageData added in v0.45.0

func NewImageData(ic *imaging.Image) (ans *ImageData)

func OpenImageFromPath

func OpenImageFromPath(path string, opts ...imaging.DecodeOption) (ans *ImageData, err error)

func OpenImageFromReader added in v0.45.0

func OpenImageFromReader(r io.Reader, opts ...imaging.DecodeOption) (ans *ImageData, s io.Reader, err error)

func (*ImageData) Resize

func (self *ImageData) Resize(x_frac, y_frac float64) *ImageData

func (*ImageData) Serialize added in v0.44.0

func (self *ImageData) Serialize() (SerializableImageMetadata, [][]byte)

func (*ImageData) SerializeOnlyMetadata added in v0.44.0

func (self *ImageData) SerializeOnlyMetadata() SerializableImageMetadata

type ImageFrame

type ImageFrame struct {
	Width, Height, Left, Top int
	Number                   int   // 1-based number
	Compose_onto             int   // number of frame to compose onto
	Delay_ms                 int32 // negative for gapless frame, zero ignored, positive is number of ms
	Replace                  bool  // do a replace rather than an alpha blend
	Is_opaque                bool
	Img                      image.Image
}

func ImageFrameFromSerialized added in v0.44.0

func ImageFrameFromSerialized(s SerializableImageFrame, data []byte) (aa *ImageFrame, err error)

func (*ImageFrame) Data

func (self *ImageFrame) Data() (num_channels, bits_per_channel int, has_alpha_channel bool, ans []byte)

func (*ImageFrame) DataAsSHM

func (self *ImageFrame) DataAsSHM(pattern string) (ans shm.MMap, err error)

func (ImageFrame) Resize

func (ans ImageFrame) Resize(x_frac, y_frac float64) *ImageFrame

func (*ImageFrame) SaveAsUncompressedPNG added in v0.44.0

func (self *ImageFrame) SaveAsUncompressedPNG(output io.Writer) error

func (*ImageFrame) Serialize added in v0.44.0

func (s *ImageFrame) Serialize() SerializableImageFrame

type SerializableImageFrame added in v0.44.0

type SerializableImageFrame struct {
	Width, Height, Left, Top int
	Number                   int  // 1-based number
	Compose_onto             int  // number of frame to compose onto
	Delay_ms                 int  // negative for gapless frame, zero ignored, positive is number of ms
	Replace                  bool // do a replace rather than an alpha blend
	Is_opaque                bool

	Size               int // size in bytes of the serialized data
	Number_of_channels int
	Bits_per_channel   int
	Has_alpha_channel  bool
}

type SerializableImageMetadata added in v0.44.0

type SerializableImageMetadata struct {
	Version          int
	Width, Height    int
	Format_uppercase string
	Frames           []SerializableImageFrame
}

Jump to

Keyboard shortcuts

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