image

package
v0.1.4 Latest Latest
Warning

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

Go to latest
Published: Oct 4, 2026 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Overview

Package image 将单页图片和多页 TIFF 导入为带图片与 OCR 文字层的 OFD。

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Convert

func Convert(ctx context.Context, input any, output io.Writer, options ...Option) error

Convert 将图片输入写成 OFD。PNG/JPEG 产生单页 OFD;经典多页 TIFF 按 IFD 顺序产生多页 OFD。

Types

type Importer

type Importer struct {
	NameValue       string
	ExtensionsValue []string
}

Importer 是 converter 注册表使用的图片导入器。

func (*Importer) Extensions

func (i *Importer) Extensions() []string

func (*Importer) Import

func (i *Importer) Import(input any, output io.Writer, conv *converter.Converter) error

func (*Importer) MIME

func (i *Importer) MIME() string

func (*Importer) Name

func (i *Importer) Name() string

type Option

type Option func(*Options)

Option 修改导入选项。

func WithDPI

func WithDPI(dpi float64) Option

func WithMaxInputBytes

func WithMaxInputBytes(value int64) Option

func WithMaxPagePixels

func WithMaxPagePixels(value int64) Option

func WithMaxPages

func WithMaxPages(value int) Option

func WithMaxTotalPixels

func WithMaxTotalPixels(value int64) Option

func WithMinConfidence

func WithMinConfidence(value float64) Option

func WithOCR

func WithOCR(enabled bool) Option

func WithOCREngine

func WithOCREngine(engine ocr.Engine) Option

func WithOCRLanguage

func WithOCRLanguage(language string) Option

func WithTextMode

func WithTextMode(mode TextMode) Option

type Options

type Options struct {
	Engine         ocr.Engine
	OCRLanguage    string
	DPI            float64
	TextMode       TextMode
	MinConfidence  float64
	MaxPages       int
	MaxPagePixels  int64
	MaxTotalPixels int64
	MaxInputBytes  int64
}

Options 控制图片导入和 OCR。

type TextMode

type TextMode string

TextMode 控制 OCR 文字层的视觉呈现。

const (
	// TextInvisible 让文字层透明,保留搜索和复制能力。
	TextInvisible TextMode = "invisible"
	// TextVisible 显示文字层,适合调试 OCR 坐标。
	TextVisible TextMode = "visible"
	// TextOff 不执行 OCR,也不生成文字层。
	TextOff TextMode = "off"
)

Jump to

Keyboard shortcuts

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