imageutil

package
v0.0.3 Latest Latest
Warning

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

Go to latest
Published: Feb 9, 2026 License: MIT Imports: 9 Imported by: 0

Documentation

Overview

Package imageutil provides utilities for image extraction and writing

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CreatePNG

func CreatePNG(data []byte, width, height, bitsPerComponent int, colorSpace string) ([]byte, error)

CreatePNG wraps raw pixel data in PNG format. This is used for PDF images that use FlateDecode (raw pixel data). colorSpace should be "DeviceGray", "DeviceRGB", or "DeviceCMYK". bitsPerComponent is typically 8.

Types

type ImageWriter

type ImageWriter struct {
	OutputDir   string // Directory to write images to
	RelativeDir string // Relative path for markdown links
	// contains filtered or unexported fields
}

ImageWriter handles writing extracted images to disk

func NewImageWriter

func NewImageWriter(mdOutputPath string) (*ImageWriter, error)

NewImageWriter creates a new ImageWriter for the given markdown output path. For output.md, it creates and uses output_images/ directory.

func (*ImageWriter) GenerateFilename

func (w *ImageWriter) GenerateFilename(format string) string

GenerateFilename creates a unique filename like "image_001.png"

func (*ImageWriter) WriteImage

func (w *ImageWriter) WriteImage(img *models.ImageItem) (string, error)

WriteImage writes an image to disk and returns the relative path for markdown. If the image already has an OutputPath set, it uses that; otherwise generates one.

Jump to

Keyboard shortcuts

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