From: Mark Wooding Date: Wed, 21 Jun 2023 10:15:12 +0000 (+0100) Subject: mason/.perl-lib/TrivGal.pm: Simplify the image-type machinery. X-Git-Url: https://git.distorted.org.uk/~mdw/tgal/commitdiff_plain/e9f8c99ed456dc006c02e2dbde1568b5bb04476b?hp=aeca06d4f4211503629c46ab733ff5e1a21da3fe mason/.perl-lib/TrivGal.pm: Simplify the image-type machinery. This was really only needed for the benefit of Imlib2, which needed to be told what kind of output image file to make. GraphicsMagick doesn't have this deficiency. The MIME type stuff was never used at all. --- diff --git a/mason/.perl-lib/TrivGal.pm b/mason/.perl-lib/TrivGal.pm index f498894..2bd64ed 100644 --- a/mason/.perl-lib/TrivGal.pm +++ b/mason/.perl-lib/TrivGal.pm @@ -94,33 +94,6 @@ sub urldecode ($) { } ###-------------------------------------------------------------------------- -### Image types. - -our %TYPE; - -package TrivGal::ImageType { - sub new ($$) { - my ($cls, $ext) = @_; - return $TYPE{$ext} = bless { ext => $ext }, $cls; - } - sub ext ($) { - my ($me, @args) = @_; - return $me->{ext}; - } - sub mimetype ($@) { - my ($me, @args) = @_; - return TrivGal::read_or_set $me, $me->{mimetype}, @args; - } - sub imlibfmt ($@) { - my ($me, @args) = @_; - return TrivGal::read_or_set $me, $me->{imlibfmt}, @args; - } -} - -TrivGal::ImageType->new(".jpg")->mimetype("image/jpeg")->imlibfmt("jpeg"); -TrivGal::ImageType->new(".png")->mimetype("image/png")->imlibfmt("png"); - -###-------------------------------------------------------------------------- ### Configuration. export qw{$SCOPE $SUFFIX}; @@ -159,6 +132,9 @@ our %SIZE = (smallthumb => 96, vast => 5400, immense => 8100); +export qw{%TYPE}; +our %TYPE = map { $_ => 1 } qw{.jpg .png}; + export qw{init}; my $initp = 0; sub init () {