]> mj.ucw.cz Git - gallery.git/commitdiff
Gallery2: Post-migration checker of thumbnail aspect ratios
authorMartin Mares <mj@ucw.cz>
Sat, 29 Dec 2012 17:00:40 +0000 (18:00 +0100)
committerMartin Mares <mj@ucw.cz>
Sun, 8 Feb 2015 20:14:16 +0000 (21:14 +0100)
gal2/bin/gal-mj-migrate-check [new file with mode: 0755]

diff --git a/gal2/bin/gal-mj-migrate-check b/gal2/bin/gal-mj-migrate-check
new file mode 100755 (executable)
index 0000000..5936f32
--- /dev/null
@@ -0,0 +1,35 @@
+#!/usr/bin/perl
+# Check that thumbnail aspect ratios match pre-migration data
+
+use strict;
+use warnings;
+
+use UCW::Gallery;
+
+my $gal = UCW::Gallery->load_config;
+my $meta = $gal->read_meta($gal->cache_meta_name);
+
+open T, "gallery.thumb" or die "Cannot read gallery.thumb\n";
+my @thumbs = ();
+while (<T>) {
+       chomp;
+       my ($name, $tw, $th) = split /\s+/;
+       push @thumbs, [ $tw, $th ];
+}
+close T;
+
+for my $id (@{$meta->{sequence}}) {
+       my ($tw, $th) = @{shift @thumbs} or die;
+       my $ta = $tw / $th;
+       my $m = $meta->{photo}->{$id} or die;
+       my $pw = $m->{w};
+       my $ph = $m->{h};
+       my $pa = $pw / $ph;
+       if (abs($ta - $pa) > 0.05) {
+               if (abs($ta - 1/$pa) > 0.05) {
+                       print STDERR "$id: Mismatched aspect ratio: orig $ta (${tw}x${th}) new $pa (${pw}x${ph})\n";
+               } else {
+                       print STDERR "$id: Mismatched rotation\n";
+               }
+       }
+}