Virtual helper tag not working in config file #433
|
I'm trying to add a helper function to my ExifTool to rotate WLPG regions 180° (because of auto-orientation corruption) and I can't get it to work and I can't figure out what is wrong or how to debug it. My actual script is warn "DEBUG: Start of config";
%Image::ExifTool::UserDefined = (
'Image::ExifTool::Microsoft::MP' => {
RotateMPRegions180 => {
Writable => 'boolean',
WriteNothing => 1,
WriteSub => sub {
warn "DEBUG: In script\n";
my ($et, $val, $tagInfo) = @_;
my @rects = $et->GetValue('RegionRectangle', 'ValueConv');
return 1 unless @rects;
my @new;
my $i = 0;
foreach my $r (@rects) {
$i++;
my @v = split /, */, $r;
next unless @v == 4;
my ($x, $y, $w, $h) = @v;
warn "DEBUG: Region $i original: X=$x Y=$y W=$w H=$h\n";
my $nx = 1 - $x - $w;
my $ny = 1 - $y - $h;
warn "DEBUG: Region $i rotated: X=$nx Y=$ny W=$w H=$h\n";
push @new, join(', ', $nx, $ny, $w, $h);
}
$et->SetNewValue('RegionRectangle', \@new);
return 1;
}
}
}
);
warn "DEBUG: End of config\n";
1;I call it using And the result is I tried to use Anyone can tell me what I'm doing wrong please? |
Replies: 1 comment 2 replies
|
There is already a config file to rotate Microsoft regions. Download the Your command would be |
Yes, part of it was that you were trying to write it as a Microsoft tag. Tags that are part of a standard tag group (Microsoft, EXIF, XMP, etc) are tags that would be embedded inside the file. What you wanted was something that took an existing tag and transformed it so you could write it back into the file. This falls under the category of Composite tags.
Looking closer at your code, it might have worked as a Composite tag, though I'm not taking the time to break it down completely. You're concentrating on only the
RegionRectanglearray rather than dealing with theRegionInfoMPstructured tag (see Structured tags page) as a whole, which is the approach used in the config file.One thing …