Hi Thorsten,
In general, writing just a new header is not possible because if the length of any information changes the rest of the data must shift to accommodate the new size. There are special cases of course, but I like to keep ExifTool general if possible.
As far as the open filehandle goes, it is easy to write a perl wrapper which edits a file in place if you want (by first writing the file to memory). Here is an example of a 5-line subroutine to do this, along with script to test it out:
#!/usr/bin/perl -w
use strict;
require Image::ExifTool;
my $file = shift or die "please specify file name\n";
sub WriteFileHandleInPlace($$)
{
my ($exifTool, $fh) = @_;
my $buff;
$exifTool->WriteInfo($fh, \$buff) >= 0 or return 0;
return(seek($fh, 0, 0) and print $fh $buff);
}
open FILE, "+<$file" or die "Can't open file";
my $exifTool = new Image::ExifTool;
$exifTool->SetNewValue(Comment => 'test');
WriteFileHandleInPlace($exifTool, \*FILE) or warn "Error\n";
close FILE;
|