]> mj.ucw.cz Git - gallery.git/blob - gal/bin/gal-mj-migrate-check
UCW::Gallery::Web::Highslide: Image pages do not include JS
[gallery.git] / gal / bin / gal-mj-migrate-check
1 #!/usr/bin/perl
2 # Check that thumbnail aspect ratios match pre-migration data
3
4 use strict;
5 use warnings;
6
7 use UCW::Gallery;
8
9 my $gal = UCW::Gallery->load_config;
10 my $meta = $gal->read_meta($gal->cache_meta_name);
11
12 open T, "gallery.thumb" or die "Cannot read gallery.thumb\n";
13 my @thumbs = ();
14 while (<T>) {
15         chomp;
16         my ($name, $tw, $th) = split /\s+/;
17         push @thumbs, [ $tw, $th ];
18 }
19 close T;
20
21 for my $id (@{$meta->{sequence}}) {
22         my ($tw, $th) = @{shift @thumbs} or die;
23         my $ta = $tw / $th;
24         my $m = $meta->{photo}->{$id} or die;
25         my $pw = $m->{w};
26         my $ph = $m->{h};
27         my $pa = $pw / $ph;
28         if (abs($ta - $pa) > 0.05) {
29                 if (abs($ta - 1/$pa) > 0.05) {
30                         print STDERR "$id: Mismatched aspect ratio: orig $ta (${tw}x${th}) new $pa (${pw}x${ph})\n";
31                 } else {
32                         print STDERR "$id: Mismatched rotation\n";
33                 }
34         }
35 }