mason/.perl-lib/TrivGal.pm, mason/dhandler: Rescale images lazily.
authorMark Wooding <mdw@distorted.org.uk>
Mon, 12 Jun 2023 10:38:51 +0000 (11:38 +0100)
committerMark Wooding <mdw@distorted.org.uk>
Mon, 12 Jun 2023 10:48:39 +0000 (11:48 +0100)
commit784bdf8f1aab63a19724cb60026e78f8f7550ab8
treef0d305a9b5fb721c6d95c134f4a8ffd3a4d7b2df
parentbfc5bfe6967009433043d3aee1d74eef4b8cec8f
mason/.perl-lib/TrivGal.pm, mason/dhandler: Rescale images lazily.

If `TrivGal::Image::scale' can't find an existing scaled image, then by
default it just returns immediately with a `?scale=...' link.  The code
acting on this parameter now passes an additional FORCEP argument to
`TrivGal::Image::scale' to get it to actually generate the scaled
version.  Once the scaled version exists, `TrivGal::Image::scale'
returns a direct link to it rather than the `?scale=...' link, which
saves a redirect round trip.

This has two main effects.

  * Firstly, and most importantly, it allows the main HTML to be served
    up immediately, without waiting for the (rather time-consuming)
    image scaling to happen; and it also allows the scaling to happen
    with a certain amount of parallelism.

  * Secondly, it also isolates failures (e.g., due to exceeding memory
    limits) to individual images.
mason/.perl-lib/TrivGal.pm
mason/dhandler