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. 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.
Index ¶
Constants ¶
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.
Variables ¶
This section is empty.
Functions ¶
func Check ¶
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 ¶
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 ¶
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 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.