polaris.analysis.thumbnail.make_thumbnail
- polaris.analysis.thumbnail.make_thumbnail(plot_filename, thumbnail_filename, size=(320, 240), image_format='jpeg', quality=75)[source]
Render the thumbnail for one plot, unless it is already up to date
The plot is flattened onto white before being scaled, because the plots carry an alpha channel and JPEG has no transparency to put it in – without this the background comes out black.
The thumbnail is scaled to fit inside
sizein both dimensions rather than to a fixed width. A width rule charges the most for the tallest plots, which are the ones a reader least needs at full size: a stack of time series is three times the pixels of a map at the same width, and does not sit in a grid beside it.- Parameters:
plot_filename (str) – The plot to render, normally the published symlink
thumbnail_filename (str) – Where to write the thumbnail
size (tuple of int, optional) – The bounding box in pixels, as (width, height)
image_format ({'jpeg', 'webp'}, optional) – The format to write.
webpis between a third and a half smaller at the same quality and every current browser reads it.quality (int, optional) – The compression quality, from 1 to 100
- Returns:
rendered (bool) – Whether the thumbnail was rendered. It is left alone when it is already newer than its plot, so that adding one product to an existing analysis costs one thumbnail rather than all of them.