#!/usr/bin/perl use strict; use warnings; use File::Spec; use Panotools::Script; use Image::Size; my $img_erect = shift or die "usage\n $0 equirectangular.tif"; my $pto_mercator = $img_erect; $pto_mercator =~ s/\.([[:alnum:]]+)$/-mercator.pto/; my ($width, $height) = imgsize ($img_erect); my $height_m = int (0.6180339887 * $width); my ($volume, $directories, $file) = File::Spec->splitpath ($img_erect); my $mercator = new Panotools::Script; if (-e $pto_mercator) { $mercator->Read ($pto_mercator); $mercator->Panorama->Set (w => $width, h => $height_m); $mercator->Image->[0]->Set (w => $width, h => $height); } else { $mercator->Panorama->Set (v => 360, f => 5, u => 0, w => $width, h => $height_m, n => '"TIFF"'); $mercator->Image->[0] = new Panotools::Script::Line::Image; $mercator->Image->[0]->Set (w => $width, h => $height, v => 360, f => 4, r => 0, p => 0, y => 0, n => "\"$file\""); } $mercator->Write ($pto_mercator); __END__ =head1 NAME erect2mercator - Extract a mercator projection from an equirectangular image =head1 Synopsis erect2mercator equirectangular.tif =head1 DESCRIPTION Generates a suitably sized mercator .pto project from a 360 degree equirectangular image. Input is in any image format understood by hugin, output is in TIFF format with an aspect ratio of 1.618:1 (a golden rectangle). The output filename is derived automatically from the input filename with '-mercator.pto' appended. Existing .pto files will not be clobbered but will be updated when input images change size. L =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, L =head1 Author Bruno Postle