No description
Find a file
Repository files (latest commit first)
Filename Latest commit message Latest commit date
Humphrey Drummond 6a5d2bd300 Migrate module path from github.com to codeberg.org
Codeberg is the primary source; GitHub is a mirror.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-26 23:05:03 +00:00
.claude adding per page command 2026-03-14 01:57:36 +00:00
cmd Migrate module path from github.com to codeberg.org 2026-03-26 23:05:03 +00:00
pdfrenderer adding linting 2026-03-14 19:21:49 +00:00
.gitignore Merge branch 'task/WTcombine' 2026-03-14 16:43:23 +00:00
CHANGELOG.md Update CHANGELOG for v0.6.6 2026-03-14 20:27:33 +00:00
commands.md adding gallery 2026-03-14 02:18:37 +00:00
composite.go combining docs 2026-03-14 16:41:31 +00:00
corrupt.go Fix PDFium WASM alpha corruption and replace nfnt/resize with x/image/draw 2026-02-07 15:14:35 +00:00
gallery.md adding gallery 2026-03-14 02:18:37 +00:00
go.mod Migrate module path from github.com to codeberg.org 2026-03-26 23:05:03 +00:00
go.sum update 2026-02-12 23:25:15 +00:00
image.go adding linting 2026-03-14 19:21:49 +00:00
index.md adding gallery 2026-03-14 02:18:37 +00:00
LICENSE Adding licence 2026-02-13 09:33:43 +00:00
page.go adding per page command 2026-03-14 01:57:36 +00:00
page_test.go adding linting 2026-03-14 19:21:49 +00:00
pdf.go Migrate module path from github.com to codeberg.org 2026-03-26 23:05:03 +00:00
placeholder.go Fixing width of icons and 1.4 height 2026-02-12 01:13:34 +00:00
README.md adding per page command 2026-03-14 01:57:36 +00:00
ROADMAP.md adding per page command 2026-03-14 01:57:36 +00:00
task-plus.yml combining docs 2026-03-14 16:41:31 +00:00
Taskfile.yml updating Taskfile 2026-03-14 19:22:44 +00:00
thumbnail.go adding linting 2026-03-14 19:21:49 +00:00
thumbnail_test.go adding linting 2026-03-14 19:21:49 +00:00
tiff.go adding linting 2026-03-14 19:21:49 +00:00
uniform.go combining docs 2026-03-14 16:41:31 +00:00

go-thumbnails

Pure Go thumbnail generator for PDF, TIFF, JPEG, PNG, and GIF documents. Uses PDFium via WebAssembly — no CGo required.

Features

  • Multi-page composite thumbnails (up to 4 pages side-by-side with "+" indicator)
  • Uniform fixed-size thumbnails with page-count badge
  • Per-page thumbnail extraction via page-level API
  • Error placeholder generation with colour-coded labels
  • PDF rendering corruption detection

Installation

Library

go get github.com/drummonds/go-thumbnails

CLI

go install github.com/drummonds/go-thumbnails/cmd/thumbnails@latest

Usage

Library

import thumbnails "github.com/drummonds/go-thumbnails"

// Composite thumbnail (default)
img, err := thumbnails.Generate("doc.pdf", 128)

// Uniform style with page-count badge
img, err := thumbnails.GenerateStyled("doc.pdf", 128, thumbnails.StyleUniform)

// Generate and save to disk
err := thumbnails.GenerateAndSave("doc.pdf", "doc.tn_128.png", 128)

// Render individual pages
pages, err := thumbnails.RenderPages("doc.pdf")
for _, p := range pages {
    resized := thumbnails.ResizePage(p.Image, 128)
    // p.PageNum, p.PageCount available
}

// Render a single page
page, err := thumbnails.RenderPage("doc.pdf", 3)

CLI

thumbnails [flags] file [file...]

Flags:
  -w int        Thumbnail width (default 128)
  -o string     Output path or directory (default: alongside input)
  -style string Rendering style: composite, uniform, or page (default "composite")
  -page int     Page number for -style page (0 = all pages)

Examples:

# Composite thumbnail at default width
thumbnails doc.pdf

# Uniform style, 256px wide
thumbnails -w 256 -style uniform doc.pdf

# Extract all pages as individual thumbnails
thumbnails -style page doc.pdf

# Extract page 3 only
thumbnails -style page -page 3 doc.pdf

# Process multiple files
thumbnails -w 64 *.pdf

Supported formats

Format Multi-page Notes
PDF Yes Via PDFium WebAssembly
TIFF First page only golang.org/x/image/tiff lacks DecodeAll
JPEG No Simple resize
PNG No Simple resize
GIF No Simple resize
Documentation https://h3-go-thumbnails.statichost.page/
Source (Codeberg) https://codeberg.org/hum3/go-thumbnails
Mirror (GitHub) https://github.com/drummonds/go-thumbnails