image

package
v0.2.2 Latest Latest
Warning

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

Go to latest
Published: Sep 23, 2026 License: MIT Imports: 16 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package image provides standalone image decoding helpers that can be adapted into Paper image components.

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrCannotReadFile       = errors.New("image: cannot read file")
	ErrInvalidImage         = errors.New("image: invalid image")
	ErrInvalidDimensions    = errors.New("image: invalid dimensions")
	ErrUnexpectedImageType  = errors.New("image: unexpected image type")
	ErrUnsupportedExtension = errors.New("image: unsupported extension")
)

Errors reported when an image cannot be loaded or does not match the extension it was loaded as.

Functions

This section is empty.

Types

type Image

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

Image is a decoded image together with its format and pixel size. Use the Component, Col, Row, and AutoRow methods to place it in a document.

func LoadGIF

func LoadGIF(path string) (*Image, error)

LoadGIF reads the file at path and decodes it as GIF.

func LoadJPEG

func LoadJPEG(path string) (*Image, error)

LoadJPEG reads the file at path and decodes it as JPEG.

func LoadPNG

func LoadPNG(path string) (*Image, error)

LoadPNG reads the file at path and decodes it as PNG.

func LoadTIFF

func LoadTIFF(path string) (*Image, error)

LoadTIFF reads the file at path and decodes it as TIFF.

func LoadWebP

func LoadWebP(path string) (*Image, error)

LoadWebP reads the file at path and decodes it as WebP.

func NewGIF

func NewGIF(data []byte) (*Image, error)

NewGIF decodes GIF data. It returns an error if the bytes are not a valid GIF image.

func NewJPEG

func NewJPEG(data []byte) (*Image, error)

NewJPEG decodes JPEG data. It returns an error if the bytes are not a valid JPEG image.

func NewPNG

func NewPNG(data []byte) (*Image, error)

NewPNG decodes PNG data. It returns an error if the bytes are not a valid PNG image.

func NewTIFF

func NewTIFF(data []byte) (*Image, error)

NewTIFF decodes TIFF data. It returns an error if the bytes are not a valid TIFF image.

func NewWebP

func NewWebP(data []byte) (*Image, error)

NewWebP decodes WebP data. It returns an error if the bytes are not a valid WebP image.

func (*Image) AutoRow

func (img *Image) AutoRow(rectProps ...props.Rect) core.Row

AutoRow returns the image as a row whose height follows the image itself.

func (*Image) Bytes

func (img *Image) Bytes() []byte

Bytes returns a copy of the encoded image data.

func (*Image) Col

func (img *Image) Col(size int, rectProps ...props.Rect) core.Col

Col returns the image as a column spanning size grid units.

func (*Image) Component

func (img *Image) Component(rectProps ...props.Rect) core.Component

Component returns the image as a component that can be added to a column.

func (*Image) Dimensions

func (img *Image) Dimensions() *entity.Dimensions

Dimensions returns the pixel width and height as an entity.Dimensions.

func (*Image) Extension

func (img *Image) Extension() extension.Type

Extension returns the image format.

func (*Image) Height

func (img *Image) Height() int

Height returns the image height in pixels.

func (*Image) Row

func (img *Image) Row(height float64, rectProps ...props.Rect) core.Row

Row returns the image as a row of the given height in millimeters.

func (*Image) Width

func (img *Image) Width() int

Width returns the image width in pixels.

Jump to

Keyboard shortcuts

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