images

package
v0.7.0 Latest Latest
Warning

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

Go to latest
Published: Nov 20, 2026 License: BSD-2-Clause Imports: 8 Imported by: 0 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 images encodes images for a model to look at.

Index

Constants

This section is empty.

Variables

View Source
var ErrPixelFormat = errors.New("images: unsupported pixel format")

ErrPixelFormat is returned for raw pixels in a format Encode cannot read.

View Source
var ErrPixelSize = errors.New("images: pixels do not match the image size")

ErrPixelSize is returned for raw pixels that do not fill the size given.

Functions

func Channels added in v0.7.0

func Channels(format string) int

Channels is the number of bytes a pixel takes in a raw pixel format, or 0 for a format Resize cannot read. Empty is RGB.

func Encode

func Encode(img []byte, width, height int, format string) ([]byte, string, error)

Encode encodes an image for a model to look at, and returns the encoded bytes and their MIME type.

An image whose format is a MIME type is already encoded and keeps its bytes. Raw pixels are encoded as a JPEG, without their alpha channel: format is the pixel format, "RGB", "RGBA", "RGBX" or "L" (8-bit grey), and empty is RGB.

func Resize added in v0.7.0

func Resize(img []byte, width, height int, format string, newWidth, newHeight int) ([]byte, error)

Resize scales raw pixels to a new size with a bicubic filter, keeping their pixel format: "RGB", "RGBA", "RGBX" or "L" (8-bit grey), and empty is RGB.

The filter widens with the scale when shrinking, so every source pixel counts toward the result rather than the image being sampled at a few points.

Types

This section is empty.

Jump to

Keyboard shortcuts

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