Beefy Boxes and Bandwidth Generously Provided by pair Networks
Come for the quick hacks, stay for the epiphanies.
 
PerlMonks  

comment on

( #3333=superdoc: print w/replies, xml ) Need Help??
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!
MrCromeDome


In reply to Perl::Magick maxes my systems processor usage by MrCromeDome

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others studying the Monastery: (4)
As of 2023-11-29 12:42 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?