Skip to main content

Module thumbnail

Module thumbnail 

Source
Expand description

Thumbnail rules and rendering, following Eagle’s thumbs/ modules.

Eagle stores thumbnails as lossy WebP (quality 75) under the name <name>_thumbnail.png; sides above 16383 px fall back to JPEG at 0.7. See the thumbnails chapter of the docs for what is observed and inferred.

Structs§

PageThumbnail
A page screenshot made ready to save: encoded and its palette taken. Slow, and needs no library.
Plan
What to do about an item’s thumbnail.
Spotlight
What Spotlight knows about a file’s pixel size and duration.
ThumbError
Failure while decoding, rendering or encoding an image.

Enums§

QuickLookStop
Why quicklook_until gave no picture.

Constants§

CUSTOM_THUMBNAIL_KEY
Item key Eagle sets when the thumbnail was chosen by the user.
CUSTOM_THUMBNAIL_MAX_BYTES
Largest file Eagle accepts as a custom thumbnail, in bytes.
DEFAULT_MAX_SIDE
Short-side limit for ordinary images.
FRAME_THUMBNAIL_SIDE
Short side a frame chosen in the GIF player is brought down to.
JPEG_QUALITY
JPEG quality (0.7) used past MAX_WEBP_SIDE.
MAX_WEBP_SIDE
Largest side WebP can hold; beyond it Eagle writes JPEG.
NO_THUMBNAIL_FILE_SIZE
… as long as its file is no larger than this many bytes.
NO_THUMBNAIL_SIZE
An image up to this many pixels per side may be shown without a thumbnail.
PNG_FORCE_THUMBNAIL_SIZE
A PNG this large always gets a thumbnail, whatever its dimensions.
QUICKLOOK_SIZE
Long side of QuickLook renders, matching the size Eagle reports for documents such as PDFs.
QUICKLOOK_TIMEOUT
How long a QuickLook render may take.
SVG_INLINE_LIMIT
SVGs smaller than this (bytes) are displayed directly.
THUMBNAIL_AT_KEY
Item key Eagle sets to the second a video’s thumbnail was taken at.
VIDEO_THUMBNAIL_WIDTH
Width Eagle draws a video’s thumbnail at, whatever the video’s size.
WEBP_QUALITY
WebP quality used by Eagle.

Functions§

custom_thumbnail_allowed
Whether an item of this extension may get a custom thumbnail. Eagle hides the command for the image formats it shows as themselves (tif, jpg, png, bmp, webp); jpeg and tiff are falcon’s addition, as the same formats.
custom_thumbnailed
The file work of crate::Library::set_custom_thumbnail, without the library: checks image, copies it over the thumbnail of item (in the library at root) and returns the item as it should be saved. Lets a caller that shares the library read and write files without holding its lock.
decode
Decodes a raster image, applying its EXIF orientation. Sniffs the format from content, so it also reads Eagle’s WebP-in-.png thumbnails.
decode_for_display
decode for showing: the pixels are turned into sRGB through the file’s colour profile (see crate::color). Whatever rewrites the file uses decode instead.
encode
Encodes img as Eagle does: lossy WebP at quality 75, or JPEG at 0.7 when a side exceeds 16383 px.
frame_thumbnail_size
The size Eagle draws a GIF frame thumbnail at: the short side brought down to FRAME_THUMBNAIL_SIDE, never enlarged.
has_custom_thumbnail
Whether the item’s thumbnail was set by hand (customThumbnail: true).
is_supported
Whether falcon can decode and thumbnail this extension (lowercase, no dot).
jpeg
img as a JPEG at quality (1..=100), alpha dropped.
max_side
The short-side limit for ext: 320 for ordinary images, 512 for icon formats, 480 for documents, design files and other large-canvas formats. 3D models are not scaled down: Eagle keeps its 1080 render (plus the padding) as is.
plan_raster
Plan for a raster image of w x h pixels and file_size bytes.
plan_svg
Plan for an SVG of file_size bytes whose render succeeded. A thumbnail is always rendered (it feeds the palette); small SVGs delete it afterwards.
plan_svg_failed
Plan for an SVG that failed to render: no thumbnail, noThumbnail only.
quicklook
Renders a preview of any file macOS QuickLook understands, with its long side at most size.
quicklook_until
quicklook, giving up after timeout or once cancel is set, either of which kills qlmanage.
raw_preview
The largest JPEG preview embedded in a RAW photo, turned by the file’s EXIF orientation when it has one (from its TIFF IFDs, RAF’s preview EXIF, CR3’s CMT1, MRW’s TTW block, X3F’s preview or CRW’s rotation record; see crate::exif::orientation). Eagle’s RAW viewer shows the preview dcraw extracts; falcon finds the same kind of picture by scanning for baseline or progressive 8-bit JPEG streams and keeping the one with the most pixels (the camera’s full-size preview rather than its thumbnail), in sRGB when the preview has a colour profile.
redrawn
The file work of Refresh Thumbnail, without the library: re-reads the original’s file times, redraws thumbnail and palette, and returns the item as it should be saved.
render_svg
Renders an SVG. With max, it is drawn straight at target_size; without, at its natural size.
render_svg_region
Renders part of an SVG at size pixels: region is the part to draw, as fractions of the drawing ([x0, y0, x1, y1], 0..1). The viewer uses it to stay sharp when zoomed in, drawing only what is on screen.
resize
Scales img per target_size; returns it unchanged when it fits.
resize_with
resize with an explicit filter.
spotlight
Reads pixel size and duration from Spotlight (mdls). Files Spotlight hasn’t indexed, such as ones in temporary folders, give nothing.
svg_size
Natural pixel size of an SVG file’s contents.
target_size
Target size for a w x h image with short-side limit max.
video_thumbnail_jpeg
Encodes a video frame the way Eagle’s thumbnailer does: drawn at video_thumbnail_size and saved as a JPEG at full quality. Eagle writes those JPEG bytes under the usual _thumbnail.png name.
video_thumbnail_size
The size of Eagle’s video thumbnail for a w × h frame: 480 wide, the height scaled to match and cut to whole pixels (a canvas size).
write_encoded
Encodes img as is and writes it to dest.
write_thumbnail
Resizes img to the limit max and writes the encoded thumbnail to dest.