#!/usr/bin/perl
pod2usage (2)
unless
(
scalar
@ARGV
);
for
my
$path_jpeg
(
@ARGV
)
{
print
"JPEG file: $path_jpeg\n"
;
my
$exiftool
= new Image::ExifTool;
$exiftool
->Options (
PrintConv
=> 0);
my
$imageinfo
=
$exiftool
->ImageInfo (
$path_jpeg
);
unless
(
defined
$imageinfo
->{ProjectionType} and
$imageinfo
->{ProjectionType} eq
'equirectangular'
)
{
print
"Skipping: Incomplete XMP GPano tags\n"
;
next
;
}
my
$hfov
= 360 *
$imageinfo
->{CroppedAreaImageWidthPixels} /
$imageinfo
->{FullPanoWidthPixels};
my
$vfov
= 180 *
$imageinfo
->{CroppedAreaImageHeightPixels} /
$imageinfo
->{FullPanoHeightPixels};
my
$e
=
$imageinfo
->{CroppedAreaTopPixels} + ((
$imageinfo
->{CroppedAreaImageHeightPixels} -
$imageinfo
->{FullPanoHeightPixels}) / 2);
my
$path_pto
=
$path_jpeg
;
$path_pto
=~ s/\.jpg/_remap.pto/i;
my
$pto
= new Panotools::Script;
$pto
->Panorama->{f} = 19;
$pto
->Panorama->{v} =
$hfov
;
$pto
->Panorama->{w} =
$imageinfo
->{CroppedAreaImageWidthPixels};
$pto
->Panorama->{h} =
$imageinfo
->{CroppedAreaImageHeightPixels} +
abs
(
$e
* 2);
$pto
->Panorama->{n} =
"\"JPEG q90\""
;
$pto
->Option->{outputImageType} =
'jpg'
;
$pto
->Option->{outputJPEGQuality} = 90;
$pto
->Image->[0] = new Panotools::Script::Line::Image;
$pto
->Image->[0]->{f} = 4;
$pto
->Image->[0]->{v} =
$hfov
;
$pto
->Image->[0]->{w} =
$imageinfo
->{CroppedAreaImageWidthPixels};
$pto
->Image->[0]->{h} =
$imageinfo
->{CroppedAreaImageHeightPixels};
$pto
->Image->[0]->{e} = 0 -
$e
;
$pto
->Image->[0]->{n} =
"\"$path_jpeg\""
;
$pto
->Write (
$path_pto
);
}