MrCromeDome has asked for the wisdom of the Perl Monks concerning the following question:

I've posted this same question to an Image::Magick forum, but figured if someone here had some insight, I'd appreciate it that much more.

I'm writing an image conversion in Perl. It takes single-page Group III TIFF images and writes them into a multi-page Group 4 TIFF file. Along the way, it creates new indexing information in our database so we can find the new image (as opposed to the old ones). The problem is that when Perl attempts to write the image to disk, my processor utilization hits 100%. When writing is complete, CPU usage drops and processing picks up till the next image write.

I have extracted enough of my code to illustrate my point:
# Create a new image handler my $img = Image::Magick->new; # Read database, set some values here # Read the image $success = $sth_multi_select->execute($image_id); print LOG "Can't get page information for document $document: ", $dbh_source->errstr, "\n" unless defined $success; next unless $success; $sth_multi_select->bind_columns( \$page_number, \$old_filename, \$old_directory, \$old_volume); while($sth_multi_select->fetch()) { my $path = "$volume_list{$old_volume}\\" . ($old_directory eq "" ? "" : "$old_directory\\") . "$old_filename"; $success = $img->read($path); print LOG "Can't read document $document: ", $success, "\n" if $su +ccess; } # Write index entries to database here # Write out the new image - GETS SLOW HERE! my $path = "$dest_path$filename"; print "Before\n"; $success = $img->write($path); print "After\n"; print LOG "Can't write document $document: ", $success, "\n" if $succe +ss; undef $img;
As my program executes, it appears to hang for a REALLY long time after printing "Before". I checked the task manager at this point and see my processor usage at 100%. As soon as "After" prints, I check the task manager again and my CPU usage is back to an acceptable level. No errors are triggered, and the image I expect to be created is (with the proper number of pages). This type of behavior occurs even for one and two page documents, where the resulting image is only about 30-50k or so.

I am using the latest ActiveState Perl 5.8.0 and ImageMagick-5.5.6-Q8-windows (Q8 boasts less memory and CPU requirements than Q16) on Windows NT Server 4.0 SP 6.

Any insight is appreciated. Thank you!