Documentation
¶
Index ¶
- func DefaultThumbnailPath(docPath string, width uint) string
- func ErrorPlaceholder(label string, width uint) image.Image
- func Generate(filePath string, width uint) (image.Image, error)
- func GenerateAndSave(filePath, outputPath string, width uint) error
- func GenerateOrPlaceholder(filePath string, width uint) image.Image
- func GenerateStyled(filePath string, width uint, style Style) (image.Image, error)
- func GenerateStyledAndSave(filePath, outputPath string, width uint, style Style) error
- type CorruptionResult
- type Style
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DefaultThumbnailPath ¶
DefaultThumbnailPath returns the conventional thumbnail path for a document. e.g. "doc.pdf" -> "doc.tn_64.png"
func ErrorPlaceholder ¶
ErrorPlaceholder generates a coloured placeholder image with the given label. The image is width × pageHeight(width) with white centred text.
func Generate ¶
Generate reads a file from disk and returns a composite-style thumbnail. Width is the desired thumbnail width in pixels; height is width × √2 (A4 ratio). Supported formats: PDF, TIFF (multi-page composite), JPG, PNG (simple resize).
func GenerateAndSave ¶
GenerateAndSave generates a composite-style thumbnail and saves it as PNG to outputPath.
func GenerateOrPlaceholder ¶
GenerateOrPlaceholder wraps Generate: on success it returns the real thumbnail; on any error it returns a placeholder image indicating the error type. It never returns nil.
func GenerateStyled ¶
GenerateStyled reads a file and returns a thumbnail in the given style.
Types ¶
type CorruptionResult ¶
type CorruptionResult struct {
// Corrupt is true if the image appears corrupted.
Corrupt bool
// Reason describes the type of corruption detected.
Reason string
// CorruptRowFraction is the fraction of rows with non-grayscale artifacts (0.0–1.0).
CorruptRowFraction float64
// NonOpaqueRowFraction is the fraction of rows containing non-opaque (alpha != 255) pixels.
NonOpaqueRowFraction float64
}
CorruptionResult describes corruption detected in a rendered page.
func CheckPageCorruption ¶
func CheckPageCorruption(img image.Image) CorruptionResult
CheckPageCorruption detects rendering corruption in a single page image.
PDFium can produce corrupt RGBA buffers where pixel data contains garbage bytes with non-255 alpha values and spurious colour in what should be grayscale or clean colour content. The key signal is rows where a high fraction of pixels have alpha != 255 — legitimate document renders are fully opaque.
func CheckThumbnailCorruption ¶
func CheckThumbnailCorruption(img image.Image) CorruptionResult
CheckThumbnailCorruption checks a final composited thumbnail for corruption. This catches issues that survive resizing/compositing.
type Style ¶
type Style int
Style controls the thumbnail rendering mode.
const ( // StyleComposite renders multi-page documents as side-by-side page tiles // with a "+" indicator for documents with more than 4 pages. StyleComposite Style = iota // StyleUniform renders all documents as a fixed width × 1.42×width thumbnail // with a page-count watermark for multi-page documents. StyleUniform )
Source Files
¶
Directories
¶
| Path | Synopsis |
|---|---|
|
cmd
|
|
|
batch
command
|
|
|
diagnose
command
|
|
|
gentestimages
command
Command gentestimages creates PNG and JPEG test images in testdata/.
|
Command gentestimages creates PNG and JPEG test images in testdata/. |
|
showcase
command
Command showcase generates sample thumbnails into a temporary directory so you can visually inspect the output of every supported path.
|
Command showcase generates sample thumbnails into a temporary directory so you can visually inspect the output of every supported path. |