picture

package
v0.1.28 Latest Latest
Warning

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

Go to latest
Published: Nov 5, 2026 License: Apache-2.0 Imports: 10 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 picture reads the pictures of a module for what the format asks of them but does not refuse: a picture SHOULD have an opaque background, and module-kit warns of one with a pixel that is not fully opaque (format/README.md, section 14; the second amendment of 2026-11-01 to R51 in spec). A warning is no rule: it has no ID and no test vectors, and refuses nothing (R39).

Warnings reads every PNG and WebP file under media/ of a module's folder, decodes it — PNG by image/png, WebP by golang.org/x/image/webp — and gives a Warning for each picture with a pixel whose alpha is below full, naming the first such pixel; and for each picture it could not check: one larger than MaxPixels, which it does not decode, and one it cannot decode, such as an animated WebP. A JPEG has no transparency, and a sound none either.

The CLI's check calls it, and module-registry will from stage 4. It stands apart from package module, so that api, which takes package module through modulepackage, carries no decoder of pictures (R38).

Index

Constants

View Source
const MaxPixels = 1 << 25

MaxPixels is the most pixels a picture may have for Warnings to decode it: 1<<25, 33 554 432, such as 5792 × 5792. A picture decodes into at most 8 bytes a pixel, so one takes at most 256 MiB, and a file whose header names a larger size, as a picture packed to explode would, is not decoded but warned of (R39).

Variables

This section is empty.

Functions

func Check

func Check(name string, data []byte) (message string, warn bool)

Check reads one picture, the bytes of a file named name, by the format its extension names, .png or .webp in lowercase, as media_path has them, and says what to warn of, if anything: a pixel that is not fully opaque, the first in the order of rows; a size above MaxPixels; or a file it cannot decode. A file of another extension gives no warning, and neither does one that does not begin with the signature of its format: the check of the module refuses it by module.media, and a warning would say it twice.

Types

type Warning

type Warning struct {
	Path    string
	Message string
}

A Warning is what a picture of a module asks of its author, though the format refuses nothing for it: Path is the file from the module's folder, with / between names, and Message says what.

func Warnings

func Warnings(ctx context.Context, fsys fs.FS) ([]Warning, error)

Warnings reads each PNG and WebP file under media/ of the module whose folder is the root of fsys, in the order of their paths, and gives a warning for each picture with a pixel that is not fully opaque, and for each it could not check. A module with no media/ has none. Files and folders whose names begin with "." are not the module's (format/README.md, section 10) and are skipped. The error is for a folder or a file that could not be read, or ctx once it is done, and then there are no warnings.

func (Warning) String

func (w Warning) String() string

Jump to

Keyboard shortcuts

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