#!/usr/bin/perl
use strict;
use warnings;
use Panotools::Script;
use Getopt::Long;
use Pod::Usage;
my $path_output;
my $help = 0;
GetOptions ('o|output=s' => \$path_output,
'h|help' => \$help);
pod2usage (-verbose => 2) if $help;
my $path_pto = shift || pod2usage;
die "Can't find $path_pto" unless -e $path_pto;
my $p = new Panotools::Script;
$p->Read ($path_pto);
$p->Panorama->{w} *= 2;
$p->Panorama->{h} *= 2;
for my $i (@{$p->Image})
{
$i->{w} *= 2;
$i->{h} *= 2;
$i->{d} *= 2 if $i->{d} =~ /^[-0-9.]+$/;
$i->{e} *= 2 if $i->{e} =~ /^[-0-9.]+$/;
$i->{Vx} *= 2 if $i->{Vx} =~ /^[-0-9.]+$/;
$i->{Vy} *= 2 if $i->{Vy} =~ /^[-0-9.]+$/;
if (defined $i->{S})
{
my @S = split (',', $i->{S});
@S = map {int ($_ * 2)} @S;
$i->{S} = join ',', @S;
}
}
for my $c (@{$p->Control})
{
$c->{x} *= 2;
$c->{y} *= 2;
$c->{X} *= 2;
$c->{Y} *= 2;
}
for my $k (@{$p->Mask})
{
my $string = $k->{p};
$string =~ s/"//g;
my @p = split (' ', $string);
@p = map {int ($_ * 2)} @p;
$k->{p} = '"'. (join ' ', @p) .'"';
}
$p->Write ($path_output);
exit 0;
__END__
=head1 NAME
ptodouble - rescale a panorama project
=head1 SYNOPSIS
ptodouble [options] --output doubled.pto project.pto
Options:
-o | --output Filename of scaled project (can be the the same as the input)
-h | --help Outputs help documentation
=head1 DESCRIPTION
B<ptodouble> takes a hugin .pto project and doubles all pixel dimensions.
You will need to rescale the photos to match:
mogrify -geometry 200% *.JPG
Note, this tool is useful in conjunction with the L<ptohalve> tool which
performs the opposite transform.
=head1 LICENSE
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
=head1 SEE ALSO
L<http://hugin.sourceforge.net/>
L<ptohalve>
=head1 AUTHOR
Bruno Postle - January 2011.
=cut