picture

package
v0.0.128 Latest Latest
Warning

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

Go to latest
Published: Dec 4, 2026 License: GPL-3.0 Imports: 6 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 picture makes the pictures the server derives from an image: the thumbnails, a HEIF photo's viewing copy, avatars and emoji. Scaling is bild's Catmull-Rom resampler; turning a picture upright per its EXIF orientation is a plain remapping of its pixels.

Every picture comes back as *image.NRGBA, colour not premultiplied by alpha: that is how the WebP encoder reads pixels (it takes an *image.RGBA's bytes as they are, which would darken every partly transparent pixel).

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Fill

func Fill(img image.Image, w, h int) *image.NRGBA

Fill scales the centre of img, cut to the shape of w×h, to exactly w×h.

func Fit

func Fit(img image.Image, w, h int) *image.NRGBA

Fit scales img down to fit within w×h, keeping its shape. An image that fits already keeps its size: it is never enlarged.

func JPEGOrientation

func JPEGOrientation(header []byte) int

JPEGOrientation is the EXIF orientation (1–8) in a JPEG's header, or 0 when it has none (or is no JPEG). An unreadable one is none: the image is then shown as stored.

func RGBA

func RGBA(img image.Image) *image.RGBA

RGBA is img as the resizer reads it: img itself when it already is an *image.RGBA, otherwise a copy, 4 bytes a pixel. Convert once when several pictures are made from one image.

func ShownSize

func ShownSize(w, h, orientation int) (int, int)

ShownSize is the size of w×h stored pixels as shown: orientations 5–8 turn them a quarter.

func Shrink

func Shrink(img image.Image, orientation, w, h int) *image.NRGBA

Shrink fits img within a w×h box as it is shown, then turns it upright: stored turned a quarter (orientations 5–8), it fits the box turned a quarter.

func Upright

func Upright(img *image.NRGBA, orientation int) *image.NRGBA

Upright turns pixels as stored the way EXIF orientation shows them. As stored (1), or no orientation (0 or anything unknown), is img itself.

Types

This section is empty.

Jump to

Keyboard shortcuts

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