Slow exifTool->WriteInfo ?

Started by Archive, May 12, 2010, 08:54:30 AM

Previous topic - Next topic

Archive

[Originally posted by justinc on 2009-01-29 13:30:00-08]

I am trying to add the filename of the tiff-file  to a tag called DocumentName.

It works, but it takes about about a second per file.

I have several thousand files per day, so the speed is rather important to me.

Any comments?

Code:
sub addExifTagToTiffs($@)
{
        my ($filesdir,@currentFilesToEdit) = @_;
        my $tag = 'DocumentName';
        my $retVal = 0;

        print "currentFilesToEdit: @currentFilesToEdit \n";

        foreach my $filename (@currentFilesToEdit)
        {
                $filepath = $filesdir . '/' . $filename;

                my $exifTool = new Image::ExifTool;

                my $val = $exifTool->GetValue($tag);
                if (ref $val eq 'SCALAR'){print "$tag = (unprintable value), returns\n";return $retVal;}
                else {print "tag: $tag = '$val'\n";}

                #check if the tag is set already, if it is check the value
                if ($val ne "")
                {
                        print "check  the tag as it is not empty \n";
                        if ($val ne $filename){print "value of tag is not as expected\n";return $retVal;}
                }

                ($success, $errStr) = $exifTool->SetNewValue($tag,$filename);
                print "success: $success, errStr: $errStr \n";
                if ($success==0){return $retVal;}
                my $write_result = $exifTool->WriteInfo($filepath);

                print "write_result: $write_result \n";
                if ($write_result==0){return $retVal;}

        }
        $retVal = 1;
        return $retVal;
}

Regards, Just

Archive

[Originally posted by exiftool on 2009-01-29 14:58:44-08]

Hi Just,

In my experience, exiftool can rewrite a TIFF image just about as
fast as you can copy it using a system copy command.  If these
are big files (>~10MB), 1 sec is not unusual.  Here is an excerpt
from a console session on my system:

Code:
> ls -l b.tif
-rw-r--r--   1 phil  phil  8975454 Apr  9  2008 b.tif

> time cp b.tif c.tif
0.000u 0.035s 0:00.90 3.3%      0+0k 0+9io 0pf+0w

> time exiftool c.tif "-documentname<filename"
    1 image files updated
0.568u 0.138s 0:00.75 92.0%     0+0k 0+24io 0pf+0w

The straight copy of this 8+MB tiff image took 0.90 seconds of
"real" time.  Most of this was waiting for the disk i/o because the
CPU time is much less.

But the cool thing is that exiftool can rewrite the image in 0.75
seconds.  So on this Unix-based system, exiftool is faster than the 'cp'
command.  It takes more CPU time, but the disk i/o must be much
more efficient, giving better overall performance than a system copy.

However, in the past I have seen poor performance on Windows with
some tiff images due to inefficient memory handling routines in
ActivePerl.  But I thought this problem was fixed.

- Phil

Archive

[Originally posted by exiftool on 2009-01-29 15:12:11-08]

Oh, wait.  I realized that the exiftool command above must
be benefitting from a system hard disk cache since the file
was just accessed with the 'cp' command.  So this test was
unfair.  If I flush the disk cache by copying a mass of huge,
unrelated files before running the exiftool command, it
takes 1.36 seconds instead of 0.75.  Still not too bad, --
only about 40% slower than a system copy command.

- Phil