Skip to content

Thumbnail Generation and Storage

Introduction

PhotoPrism currently uses the disintegration/imaging package to generate thumbnail images that are displayed in search results and in the full-screen viewer.

The smallest configurable size limit is 720px, which corresponds to the fit_720 thumbnail type. All sizes up to 720x720 will be generated by default and should therefore always be available.

Besides their obvious use in the frontend, the indexer uses thumbnails for color detection, face detection, and image classification, see Advanced Settings in the User Guide.

Thumbnail Types

The smallest configurable static and dynamic size limit is 720px, so all formats up to fit_720 should be generated by default while indexing.

Higher settings allow PhotoPrism to generate thumbnails with more detail in higher resolutions - either statically (while indexing) or dynamically (on-demand).

Name Width Height Common Use
colors 3 3 Color Detection
tile_50 50 50 List Preview
tile_100 100 100 Maps Preview
tile_224 224 224 Mosaic Preview
left_224 224 224 TensorFlow
right_224 224 224 TensorFlow
tile_500 500 500 Cards Preview
fit_720 720 720 Mobile, TV
fit_1280 1280 1024 Mobile, HD Ready TV
fit_1920 1920 1200 Mobile, Full HD TV
fit_2048 2048 2048 Tablets, Cinema 2K
fit_2560 2560 1600 Quad HD, Retina Display
fit_3840 3840 2400 Ultra HD
fit_4096 4096 4096 Ultra HD, Retina 4K
fit_7680 7680 4320 8K Ultra HD 2, Retina 6K

internal/thumb/sizes.go

Storage Folders

Generated thumbnails are cached in sub-folders of /storage/cache/thumbnails based on the SHA1 hash of the original file, for example:

/storage/cache/thumbnails/1/a/3/1a30c1f...9_100x100_center.jpg

Downscaling Filters

Linear

Bilinear interpolation takes a weighted average of the four neighborhood pixels to calculate its final interpolated value. The result is a much smoother image than the original image. When all known pixel distances are equal, then the interpolated value is simply their sum divided by four. This technique performs interpolation in both directions, horizontal and vertical. This technique gives better result than nearest neighbor interpolation and take less computation time compared to bicubic interpolation.

Cubic

Catmull-Rom is a local interpolating spline developed for computer graphics purposes. Its initial use was in design of curves and surfaces, and has recently been used in several applications. Catmull-Rom splines are a family of cubic interpolating splines formulated such that the tangent at each point is calculated using the previous and next point on the spline. The results are similar to ones produced by bicubic interpolation with regards to sharpness, but the Catmull-Rom reconstruction is clearly superior in smooth signal region.

Lanczos

The Lanczos interpolation function is a mathematical formula used to smoothly interpolate the value of a digital image between its samples. It maps each sample of the given image to a translated and scaled copy of the Lanczos kernel, which is a sinc function windowed by the central hump of a dilated sinc function. The sum of these translated and scaled kernels is then evaluated at the desired pixel. Lanczos interpolation has the best properties in terms of detail preservation and minimal generation of aliasing artifacts for geometric transformations not involving strong down sampling. However higher order Lanczos interpolation requires high computational time, which makes it unsuitable for most commercial software.

Blackman

Blackman is a modification of Lanczos that has better control of ringing artifacts.

Server API

Like most commercial image hosting services, we have chosen to implement a cookie-free thumbnail API to minimize request latency by avoiding unnecessary network traffic.

Learn more ›

Further Reading