Documentation
¶
Overview ¶
Package thumbnail draws a thumbnail image of a BDF document: the top of the first page of a text document, the whole first slide or drawing, or the top-left corner of a spreadsheet.
The layout follows the kind of document (Meta.Source, then the view):
- Crop (Word, HTML, Markdown, Excel, CSV, Parquet, scores from MML, MIDI and MusicXML, font files, whose overview starts with the name and a specimen, audio files, whose card starts with the cover; PDF and TIFF pages taller than wide): a square from the top-left corner of the first page, as wide as the page, scaled to Size × Size. A scroll view is cut from its top; a sheet from cell A1, with gridlines: the square is Size pixels at SheetDPI, so that a smaller thumbnail shows fewer cells instead of smaller ones, from MinSheetSide to MaxSheetSide units and no larger than the sheet.
- Fit (PowerPoint, Visio, draw.io, CAD drawings and plots, circuit boards, Illustrator, Photoshop, images, EPUB covers; other PDF and TIFF pages): the whole first page scaled so that its longer side is Size pixels.
A thumbnail shows the first page of a view only: a document converted for its thumbnail alone needs no more than that page, converted with converter.Options{Pages: converter.PageList(1)} (the whole of a long PDF takes seconds, its first page milliseconds).
Thumbnails show the content of a document outside the document: whoever makes one of a password-protected input should keep it as protected as the input (the bdf command does not make one unless asked to).
Index ¶
Constants ¶
const ( MinSheetSide = 96 MaxSheetSide = 480 )
MinSheetSide and MaxSheetSide bound the square of a sheet a thumbnail shows, in units: a small thumbnail still shows a few rows and columns (6 rows of 15 units), a large one shows the corner at A1 in more detail.
const ( PNG = "png" JPEG = "jpeg" WebP = "webp" )
Formats of Encode.
const DefaultSheetDPI = 72
DefaultSheetDPI is the default resolution of a sheet in a thumbnail: a unit (1/72 inch) is a pixel.
const DefaultSize = 256
DefaultSize is the default side of a thumbnail in pixels.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Mode ¶
type Mode int
Mode is how a page becomes a thumbnail.
type Options ¶
type Options struct {
// Size is the side of a cropped thumbnail and the longer side of a
// fitted one, in pixels (default DefaultSize).
Size int
// Mode picks the layout (default Auto).
Mode Mode
// View is the id of the view to draw (default: the first one).
View string
// SheetDPI is the resolution a sheet is drawn at (default
// DefaultSheetDPI): the square from A1 is Size / SheetDPI inches,
// bounded by MinSheetSide and MaxSheetSide. A lower value shows more
// cells, smaller.
SheetDPI float64
// Raster configures the drawing: fonts and background.
Raster imagebdf.Options
}
Options configures a thumbnail.