stdreg

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Dec 5, 2026 License: Apache-2.0, MIT Imports: 4 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 stdreg registers oneimage's decoders with the standard library's image package. A blank import is all it takes:

import _ "recursiveai.org/go/oneimage/stdreg"

after which image.Decode and image.DecodeConfig read PNG, JPEG, GIF, WebP, BMP, ICO and TIFF with oneimage's own decoders, so existing code gains the formats the standard library lacks (WebP, TIFF, BMP, ICO) without change.

The standard library's contract is one picture per call, so animated files give their first frame, and pixels come as stored: the Exif orientation is not applied (use oneimage.Decode for upright pixels). The result is a concrete oneimage type that implements image.Image.

image.Decode uses the first registered decoder whose signature matches, so when image/png, image/jpeg or image/gif are imported too, the one imported (initialised) first decodes those formats. Import this package before them to prefer oneimage's decoders.

Example

With the blank import, the standard library reads WebP and TIFF.

package main

import (
	"bytes"
	"fmt"
	"image"

	"recursiveai.org/go/oneimage"
)

func main() {
	src := oneimage.NewPixmap(image.Rect(0, 0, 3, 2), oneimage.NRGBA8)
	data, _ := oneimage.EncodeBytes(src, "tiff", nil)
	img, name, err := image.Decode(bytes.NewReader(data))
	fmt.Println(name, img.Bounds(), err)
}
Output:
tiff (0,0)-(3,2) <nil>

Jump to

Keyboard shortcuts

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