From: Martin Mares Date: Sat, 29 Dec 2012 17:00:40 +0000 (+0100) Subject: Gallery2: Post-migration checker of thumbnail aspect ratios X-Git-Url: http://mj.ucw.cz/gitweb/?a=commitdiff_plain;h=bc9ed57d06d250ca029af073c616846ac9fe7ebb;p=gallery.git Gallery2: Post-migration checker of thumbnail aspect ratios --- diff --git a/gal2/bin/gal-mj-migrate-check b/gal2/bin/gal-mj-migrate-check new file mode 100755 index 0000000..5936f32 --- /dev/null +++ b/gal2/bin/gal-mj-migrate-check @@ -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 () { + 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"; + } + } +}