From: Mark Wooding Date: Tue, 20 Jun 2023 20:05:19 +0000 (+0100) Subject: mason/.perl-lib/TrivGal.pm (Image): Stash `imgpath' in an object slot. X-Git-Url: https://git.distorted.org.uk/~mdw/tgal/commitdiff_plain/4fcd273f0782d7175ed1421452174233d4c5eff8 mason/.perl-lib/TrivGal.pm (Image): Stash `imgpath' in an object slot. We'll want it in more places, so it makes sense not to write the computation out each time. --- diff --git a/mason/.perl-lib/TrivGal.pm b/mason/.perl-lib/TrivGal.pm index 4e01f51..fc93772 100644 --- a/mason/.perl-lib/TrivGal.pm +++ b/mason/.perl-lib/TrivGal.pm @@ -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); }