Skip to content

Thumbnail Generation and Storage

Introduction

PhotoPrism can use libvips and the native disintegration/imaging package to generate thumbnails for display in search results and in the full-screen viewer.

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

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

Standard Sizes

The smallest configurable static and dynamic size limit is 720px, so most sizes up to fit_720 are always generated by default. Higher size limits generate thumbnails with more detail at higher resolutions - either statically (pre-generated while indexing) or on demand if the configuration permits.

Optional thumbnail sizes cannot be pre-generated and are only rendered on request, for example when sharing an image on Instagram.

The following overview shows the name, dimensions, and aspect ratio for each thumbnail size as well as a description of how it is used:

Name Width Height Aspect Ratio Available Usage
colors 3 3 1:1 Always Color Detection
tile_50 50 50 1:1 Always List View
tile_100 100 100 1:1 Always Places View
left_224 224 224 1:1 On-Demand TensorFlow
right_224 224 224 1:1 On-Demand TensorFlow
tile_224 224 224 1:1 Always TensorFlow, Mosaic View
tile_500 500 500 1:1 Always Cards View
fit_720 720 720 Preserved Always SD TV, Mobile
tile_1080 1080 1080 1:1 Optional Instagram
fit_1280 1280 1024 Preserved On-Demand HD TV, SXGA
fit_1600 1600 900 Preserved Optional Social Media
fit_1920 1920 1200 Preserved On-Demand Full HD
fit_2048 2048 2048 Preserved Optional DCI 2K, Tablets
fit_2560 2560 1600 Preserved On-Demand Quad HD, Notebooks
fit_3840 3840 2400 Preserved Optional 4K Ultra HD
fit_4096 4096 4096 Preserved On-Demand DCI 4K, Retina 4K
fit_7680 7680 4320 Preserved On-Demand 8K Ultra HD 2

internal/thumb/sizes.go

Color Profiles

sRGB is the standard color space used when generating thumbnails. An ICC color profile for wide-gamut displays can optionally be embedded.

Learn more ›

File Storage

Generated thumbnail files are stored in the storage/cache/thumbnails folder, where the path and file name depend on the thumbnail size and original file hash, e.g.:

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