From bc9ed57d06d250ca029af073c616846ac9fe7ebb Mon Sep 17 00:00:00 2001 From: Martin Mares Date: Sat, 29 Dec 2012 18:00:40 +0100 Subject: [PATCH] Gallery2: Post-migration checker of thumbnail aspect ratios --- gal2/bin/gal-mj-migrate-check | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100755 gal2/bin/gal-mj-migrate-check 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"; + } + } +} -- 2.39.2