imageconfig

package
v1.0.95 Latest Latest
Warning

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

Go to latest
Published: Sep 10, 2026 License: MIT Imports: 8 Imported by: 0

README

Image dimensions

Decode(io.ReaderAt) reads width, height and format without changing the source position. Callers upload the original bytes; they do not decode, resize or re-encode pixels. Config intentionally contains no color model. A successful result establishes dimensions, not the validity of all pixel data.

PNG, JPEG and GIF use the registered standard-library configuration readers. TIFF, BMP and WebP use independently implemented metadata readers with no external image codec dependency:

  • TIFF: classic little/big-endian TIFF, scalar SHORT/LONG width and height in the first IFD. Other tag payloads and subsequent IFDs are never followed. BigTIFF is unsupported. The 16-bit entry count bounds traversal to 65535 entries; buffers do not grow with file offsets or tag payload sizes.
  • BMP: Windows 40-, 108- and 124-byte DIB headers, including top-down images, supported palette depths, and the existing default bitfield masks. Palette reads are bounded to 1024 bytes. Pixel data is not read.
  • WebP: VP8, VP8L and VP8X dimension headers, with RIFF bounds and chunk padding included in offset calculations. Unknown chunks are skipped using random access. Traversal stops after 4096 chunks; supporting more requires an explicit resource-limit review and a real compatibility case. VP8X dimensions describe the canvas, including for animated images.

These readers validate the metadata needed for dimensions. They deliberately do not parse TIFF compression/color metadata, WebP frame bodies or embedded EXIF/ICC profiles. Do not use them as complete-file validators. If pixel processing is introduced, select and review a separate codec at that boundary instead of extending these metadata readers into decoders.

Format references:

Documentation

Overview

Package imageconfig reads dimensions without decoding image pixels.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct{ Width, Height int }

Config describes dimensions only, not a color model or validated pixel data.

func Decode

func Decode(r io.ReaderAt) (Config, string, error)

Decode reads dimensions from the beginning of r without consuming it. TIFF, BMP and WebP use bounded metadata reads, never pixel decompression. Successfully reading dimensions does not validate the complete image.

Jump to

Keyboard shortcuts

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