1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173
|
#------------------------------------------------------------------------------
# File: rotate_regions.config
#
# Description: User-defined Composite tag definitions to rotate MWG region tags
# (Metadata Working Group region, used by Picasa) and MP region tags
# (used by Microsoft Photo Library).
#
# Tag definitions and examples:
#
# RotateMWGRegionCW90
# RotateMWGRegionCW180
# RotateMWGRegionCW270
# These tags will rotate a MWG Region clockwise 90, 180, or 270 degrees.
# Example:
# exiftool -config rotate_regions.config "-RegionInfo<RotateMWGRegionCW90" FILE
#
# RotateMPRegionCW90
# RotateMPRegionCW180
# RotateMPRegionCW270
# These tags will rotate an MP Region clockwise 90, 180, or 270 degrees.
# Example:
# exiftool -config rotate_regions.config "-RegionInfoMP<RotateMPRegionCW90" FILE
#
# Revisions: 2015/05/08 - Bryan K. Williams AKA StarGeek Created
#------------------------------------------------------------------------------
%Image::ExifTool::UserDefined = (
'Image::ExifTool::Composite' => {
RotateMWGRegionCW90 =>{
Require => 'RegionInfo',
ValueConv => q{
my ($rgn, @newRgns);
foreach $rgn (@{$val[0]{RegionList}}) {
my @rect = @{$$rgn{Area}}{'X','Y','W','H'};
my %newRgn = (
Area => {
X => 1-$rect[1],
Y => $rect[0],
W => $rect[3],
H => $rect[2],
Unit => 'normalized',
},
Name => $$rgn{Name},
Type => 'Face',
);
push @newRgns, \%newRgn;
}
return {
AppliedToDimensions => {
W => $val[0]{AppliedToDimensions}{W},
H => $val[0]{AppliedToDimensions}{H},
Unit => $val[0]{AppliedToDimensions}{Unit},
},
RegionList => \@newRgns,
};
},
}, #End RotateMWGRegionCW90
RotateMWGRegionCW180 =>{
Require => 'RegionInfo',
ValueConv => q{
my ($rgn, @newRgns);
foreach $rgn (@{$val[0]{RegionList}}) {
my @rect = @{$$rgn{Area}}{'X','Y','W','H'};
my %newRgn = (
Area => {
X => 1-$rect[0],
Y => 1-$rect[1],
W => $rect[2],
H => $rect[3],
Unit => 'normalized',
},
Name => $$rgn{Name},
Type => 'Face',
);
push @newRgns, \%newRgn;
}
return {
AppliedToDimensions => {
W => $val[0]{AppliedToDimensions}{W},
H => $val[0]{AppliedToDimensions}{H},
Unit => $val[0]{AppliedToDimensions}{Unit},
},
RegionList => \@newRgns,
};
},
}, #End RotateMWGRegionCW180
RotateMWGRegionCW270 =>{
Require => 'RegionInfo',
ValueConv => q{
my ($rgn, @newRgns);
foreach $rgn (@{$val[0]{RegionList}}) {
my @rect = @{$$rgn{Area}}{'X','Y','W','H'};
my %newRgn = (
Area => {
X => $rect[1],
Y => 1-$rect[0],
W => $rect[3],
H => $rect[2],
Unit => 'normalized',
},
Name => $$rgn{Name},
Type => 'Face',
);
push @newRgns, \%newRgn;
}
return {
AppliedToDimensions => {
W => $val[0]{AppliedToDimensions}{W},
H => $val[0]{AppliedToDimensions}{H},
Unit => $val[0]{AppliedToDimensions}{Unit},
},
RegionList => \@newRgns,
};
},
}, #End RotateMWGRegionCW270
RotateMPRegionCW90=>{
Require => 'RegionInfoMP',
ValueConv => q{
my ($rgn, @newRgns);
foreach $rgn (@{$val[0]{Regions}}) {
my @rect = split /\s*,\s*/, $$rgn{Rectangle};
my $temp = $rect[0];
$rect[0] = 1-$rect[1]-$rect[3];
$rect[1] = $temp;
($rect[2], $rect[3]) = ($rect[3],$rect[2]); #Swap W and H
push @newRgns, {
PersonDisplayName => $$rgn{PersonDisplayName},
Rectangle => join(', ', @rect),
};
}
return { Regions => \@newRgns };
}
}, #end RotateMPRegionCW90
RotateMPRegionCW180=>{
Require => 'RegionInfoMP',
ValueConv => q{
my ($rgn, @newRgns);
foreach $rgn (@{$val[0]{Regions}}) {
my @rect = split /\s*,\s*/, $$rgn{Rectangle};
my $tempX = $rect[0];
my $tempY = $rect[1];
$rect[0] = 1-$tempX-$rect[2];
$rect[1] = 1-$tempY-$rect[3];
push @newRgns, {
PersonDisplayName => $$rgn{PersonDisplayName},
Rectangle => join(', ', @rect),
};
}
return { Regions => \@newRgns };
}
}, #end RotateMPRegionCW180
RotateMPRegionCW270=>{
Require => 'RegionInfoMP',
ValueConv => q{
my ($rgn, @newRgns);
foreach $rgn (@{$val[0]{Regions}}) {
my @rect = split /\s*,\s*/, $$rgn{Rectangle};
my $temp = $rect[1];
$rect[1] = 1-$rect[0]-$rect[2];
$rect[0] = $temp;
($rect[2], $rect[3]) = ($rect[3],$rect[2]); #Swap W and H
push @newRgns, {
PersonDisplayName => $$rgn{PersonDisplayName},
Rectangle => join(', ', @rect),
};
}
return { Regions => \@newRgns };
}
}, #end RotateMPRegionCW270
},
);
1; #end
|