artwork

package
v1.1.1 Latest Latest
Warning

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

Go to latest
Published: Oct 29, 2026 License: Apache-2.0 Imports: 10 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 artwork downscales and encodes images which represent documents, such as the scans of their pages, their thumbnails, and their covers

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Downscale

func Downscale(img image.Image, size int) image.Image

Downscale returns the image scaled down so its width and height are at most size, keeping its aspect ratio, or the image itself when it's smaller

func Encode

func Encode(img image.Image) []byte

Encode returns the image encoded as a greyscale PNG image when it's grey, such as a scan of a black and white document, which is smaller and sharper than a JPEG image, or else as a JPEG image

func Image

func Image(data []byte, key string, o *metadata.Opts) metadata.Metadata

Image returns the encoded image as artwork, with the key, downscaled to fit the largest image dimension when it's larger, or re-encoded when it's in a format which isn't displayed on the web, such as BMP or TIFF, or it has an orientation in its EXIF data which isn't as it is, as its EXIF data isn't kept, and otherwise as it is, or nil when it can't be decoded (see OrientedImage).

func Orient

func Orient(img image.Image, orientation int) image.Image

Orient returns the image transformed to be displayed, by its orientation, from 1 to 8, as EXIF defines it: 1 is as it is, 2 is flipped horizontally, 3 is rotated 180°, 4 is flipped vertically, 5 is transposed, 6 is rotated 90° clockwise, 7 is transverse, and 8 is rotated 90° anticlockwise. It returns the image itself for 1, or an orientation which isn't valid. A grey image stays grey, and any other is RGBA.

func OrientedImage

func OrientedImage(data []byte, key string, orientation int, o *metadata.Opts) metadata.Metadata

OrientedImage returns the encoded image as artwork, with the key, as Image does, transformed by the orientation, from 1 to 8, as EXIF defines it (see Orient), such as the orientation of a photo for its thumbnail, which has no EXIF data of its own. An image in a lossless format, such as PNG, is re-encoded as a PNG image, a JPEG image as a JPEG image, and any other as a greyscale PNG image when it's grey, or else a JPEG image.

Types

This section is empty.

Jump to

Keyboard shortcuts

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