testutil

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 testutil 提供跨包测试共享的辅助构造函数。

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func MinimalPDF

func MinimalPDF(content []byte, width, height int) []byte

MinimalPDF 返回一个最小单页 PDF,MediaBox 为 [0 0 width height],内容流为 content。

func MinimalPDFWithPage

func MinimalPDFWithPage(content []byte, mediaBox string, userUnit int) []byte

MinimalPDFWithPage 返回一个最小单页 PDF,可指定 MediaBox 与 UserUnit。

func RasterizePDFPages added in v0.1.4

func RasterizePDFPages(ctx context.Context, pdftoppm string, pdf []byte, dpi int) ([]*image.RGBA, error)

RasterizePDFPages 使用 pdftoppm 将 PDF 的所有页面栅格化为 RGBA 图像。

Types

type VisualComparison added in v0.1.4

type VisualComparison struct {
	PageCount           int
	Similarity          float64
	PixelMatchRate      float64
	MeanAbsoluteError   float64
	WorstPage           int
	WorstPageSimilarity float64
	WorstPageMatchRate  float64
}

VisualComparison 保存两组图像的视觉比较结果。

func ComparePageImages added in v0.1.4

func ComparePageImages(reference, actual []*image.RGBA, pixelTolerance uint8) (VisualComparison, error)

ComparePageImages 按页逐像素比较两组栅格图像。 pixelTolerance 是单个 RGB 通道视为匹配时允许的最大差值。

Jump to

Keyboard shortcuts

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