image

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Apr 6, 2026 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DecodePNGToRaw

func DecodePNGToRaw(pngData []byte) (raw []byte, w, h int, colorSpace string, err error)

DecodePNGToRaw decodes PNG data into raw pixel bytes suitable for a PDF image XObject. Returns the raw bytes, pixel dimensions, and the PDF color space name.

func DetectDimensions

func DetectDimensions(data []byte) (w, h int, isJPEG, isPNG bool, err error)

DetectDimensions attempts to get pixel dimensions from PNG/JPEG data without full decode.

func HasAlpha

func HasAlpha(img stdimage.Image) bool

HasAlpha returns true if any pixel in img has an alpha value less than fully opaque.

Types

type ImageInfo

type ImageInfo struct {
	Raw               []byte
	WidthPx, HeightPx int
	ColorSpace        string
	IsJPEG            bool
	BitsPerComponent  int
}

ImageInfo holds processed image data.

func ProcessImage

func ProcessImage(data []byte) (*ImageInfo, error)

ProcessImage detects format and decodes if needed.

type Options

type Options struct {
	PageIndex     int
	X, Y          float64
	Width, Height float64
	// Optional exact placement matrix (a,b,c,d,e,f) in page space. When non-zero, overrides X/Y/Width/Height.
	Matrix           [6]float64
	Data             []byte
	PixelWidth       int
	PixelHeight      int
	BitsPerComponent int
	ColorSpace       string
	AltText          string
	IsJPEG           bool
	Opacity          float64
	RotateDeg        float64
	ClipCircle       bool
	ClipCX, ClipCY   float64
	ClipRadius       float64
	IsArtifact       bool
	// Optional soft mask for alpha
	HasMask    bool
	Mask       []byte
	MaskWidth  int
	MaskHeight int
}

Options configures image placement. Used by DrawImageWith and DrawTaggedImageWith as a cleaner alternative to methods with many positional parameters.

Jump to

Keyboard shortcuts

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