mason/.perl-lib/TrivGal.pm (Image): Stash `imgpath' in an object slot.
authorMark Wooding <mdw@distorted.org.uk>
Tue, 20 Jun 2023 20:05:19 +0000 (21:05 +0100)
committerMark Wooding <mdw@distorted.org.uk>
Tue, 20 Jun 2023 20:16:11 +0000 (21:16 +0100)
We'll want it in more places, so it makes sense not to write the
computation out each time.

mason/.perl-lib/TrivGal.pm

index 4e01f51..fc93772 100644 (file)
@@ -213,7 +213,7 @@ package TrivGal::Image {
     my $imgpath = "$IMGROOT/$path";
     my $st = stat $imgpath or die "no image `$path'";
     return bless {
-      path => $path,
+      path => $path, imgpath => $imgpath,
       mtime => $st->mtime,
       img => undef
     }, $cls;
@@ -239,11 +239,10 @@ package TrivGal::Image {
 
     my $img = $me->{img};
     unless (defined $img) {
-      my $imgpath = "$IMGROOT/$path";
       my $exif = new Image::ExifTool;
-      $exif->ExtractInfo($imgpath);
+      $exif->ExtractInfo($me->{imgpath});
       my $orient = $exif->GetValue("Orientation", "ValueConv");
-      $img = $me->{img} = Image::Imlib2->load($imgpath);
+      $img = $me->{img} = Image::Imlib2->load($me->{imgpath});
       if (defined $orient) {
        my ($rot, $flip) = @{$ORIENT{$orient}};
        if ($rot) { $img->image_orientate($rot); }