chiark / gitweb /
mason/.perl-lib/TrivGal.pm: Simplify the image-type machinery.
authorMark Wooding <mdw@distorted.org.uk>
Wed, 21 Jun 2023 10:15:12 +0000 (11:15 +0100)
committerMark Wooding <mdw@distorted.org.uk>
Wed, 21 Jun 2023 10:15:12 +0000 (11:15 +0100)
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.

mason/.perl-lib/TrivGal.pm

index f498894937a8bcd7b3e2b8e32638421ddbfe4f7b..2bd64edcd9ff0c83adcced28d54aad0976e47fd2 100644 (file)
@@ -93,33 +93,6 @@ sub urldecode ($) {
   return $u;
 }
 
-###--------------------------------------------------------------------------
-### 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.
 
@@ -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 () {