coverart

package
v3.1.3 Latest Latest
Warning

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

Go to latest
Published: Aug 16, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package coverart reshapes a cover-art image without scaling it. YouTube composites an Art Track's square release art onto a 16:9 canvas and letterboxes that canvas into a 4:3 variant, so the delivered bytes carry background pillars and black rows as pixels rather than metadata. Peeling those bars and center- cropping what remains recovers the art exactly; a resize would squash it.

It is stdlib-only and pure: bytes in, bytes out, no network and no filesystem.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Dimensions

func Dimensions(data []byte) (w, h int, err error)

Dimensions reports an image's pixel size from its header, without decoding it.

func Square

func Square(data []byte) ([]byte, error)

Square crops an image down to its art: it peels uniform-color borders, then center-crops what remains to a square. It never scales, so the art keeps its proportions.

The result is square within 1%, not exactly square: an input already that close is returned untouched rather than re-encoded for a one-pixel difference. Output keeps the input's format, JPEG in / JPEG out and PNG in / PNG out.

It never returns nil bytes. On any failure it returns data unchanged along with a non-nil error, so a caller can embed the result unconditionally and treat the error as a report of a degraded result rather than a dropped one.

Types

This section is empty.

Jump to

Keyboard shortcuts

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