mason/.perl-lib/TrivGal.pm (Image::scale): Check size much earlier.
authorMark Wooding <mdw@distorted.org.uk>
Tue, 20 Jun 2023 20:19:09 +0000 (21:19 +0100)
committerMark Wooding <mdw@distorted.org.uk>
Wed, 21 Jun 2023 09:18:36 +0000 (10:18 +0100)
commit373818eb967dad9061b829700c1368835a5ba589
tree0ea1e204a9a5372c92717e61b511f6507d201b5b
parent8b97a4e3e8b71d1dda384dccdff35949e64f7dec
mason/.perl-lib/TrivGal.pm (Image::scale): Check size much earlier.

We check whether the original image is small enough to be used as-is
rather than making a scaled-down version, but currently we do that very
late, when we're actually about to try scaling it.  That's obviously a
bad idea.  Instead, check early now that we have a library that can find
an image's size without costly decoding.  In particular, this is now
done /before/ we decide whether to hand off via the `?scale=...'  lazy
thumbnailer, which is important because, in the case where the image is
small, we'll never actually make the thumbnail and we'll always pay the
redirection penalty.

This will actually slow down handling of large images; but they're kinda
inevitably a bit slow.  Besides, `Image::Size' is surprisingly fast.
mason/.perl-lib/TrivGal.pm