imaging

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Jul 12, 2026 License: MIT Imports: 12 Imported by: 0

Documentation

Overview

Package imaging decodes images for PDF embedding. JPEG is embedded losslessly via DCTDecode (original bytes passed through); PNG is decoded and re-encoded with FlateDecode, its alpha channel becoming a soft-mask (SMask). The result is ready to write as an image XObject.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Image

type Image struct {
	Width, Height    int
	ColorSpace       string // "DeviceRGB", "DeviceGray", or "DeviceCMYK"
	BitsPerComponent int
	Filter           string // "DCTDecode" or "FlateDecode"
	Data             []byte // XObject stream data (already filtered)
	SMask            []byte // optional 8-bit gray alpha, FlateDecode-compressed
	Format           string // "jpeg" or "png"
}

Image is a decoded image ready to embed as a PDF XObject.

func Decode

func Decode(data []byte) (*Image, error)

Decode sniffs the image format and decodes it.

func DecodeDataURI

func DecodeDataURI(s string) (*Image, error)

DecodeDataURI decodes a data: URI (base64 or raw payload).

func Load

func Load(src string) (*Image, error)

Load resolves an image source and decodes it. The source may be a data: URI, an http:// or https:// URL, or a local file path; any other URI scheme is rejected with a descriptive error.

func LoadFile

func LoadFile(path string) (*Image, error)

LoadFile reads an image from the local filesystem and decodes it.

func LoadURL

func LoadURL(url string) (*Image, error)

LoadURL fetches an image over HTTP(S) and decodes it.

Jump to

Keyboard shortcuts

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