Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??

On my system, this loads the (n)storable file (reconstituted from the Dumper() .txt file you linked), into a shared hash structure and then uses four threads to reconstruct the images and output the size and bounds of those images:

#! perl -slw use strict; use Data::Dump qw[ pp ]; use GD; use threads; use threads::shared; use Thread::Queue; use Storable qw[ retrieve ]; my $sem :shared; my $d = retrieve 'ex.nstored'; my %data :shared = %{ shared_clone( $d ) }; my $Q = new Thread::Queue; my @threads = map{ async { my $tid = threads->tid; while( my $key = $Q->dequeue ) { lock %{ $data{ $key } }; my $im = GD::Image->new( $data{ $key }{ 'data' } ) or die; lock $sem; printf "[$tid] size: %u x: %u y:%u\n", length( $data{ $key }{ 'data' } ), $im->getBounds; } } } 1 .. 4; $Q->enqueue( keys %data ); $Q->enqueue( (undef) x 4 ); $_->join for @threads; __END__ C:\test\tommy>test [2] size: 26859 x: 345 y:400 [3] size: 31463 x: 341 y:400 [4] size: 35596 x: 341 y:400 [1] size: 36991 x: 345 y:400 [2] size: 33427 x: 345 y:400 [4] size: 32584 x: 341 y:400 [3] size: 34196 x: 345 y:400 [2] size: 35245 x: 345 y:400 [1] size: 36410 x: 345 y:400 [4] size: 29900 x: 341 y:400 [3] size: 30204 x: 345 y:400 [2] size: 34803 x: 345 y:400 [4] size: 35809 x: 345 y:400 [1] size: 24890 x: 345 y:400 [3] size: 37982 x: 345 y:400 [2] size: 27071 x: 345 y:400 [1] size: 29397 x: 341 y:400 [4] size: 35311 x: 345 y:400 [3] size: 39712 x: 345 y:400 [2] size: 36052 x: 345 y:400 [1] size: 35227 x: 345 y:400 [4] size: 29317 x: 345 y:400 [2] size: 35901 x: 345 y:400 [3] size: 39274 x: 345 y:400 [1] size: 37797 x: 345 y:400 [4] size: 41571 x: 345 y:400 [2] size: 36599 x: 345 y:400 [3] size: 39924 x: 345 y:400 [1] size: 33219 x: 345 y:400 [4] size: 32058 x: 345 y:400 [2] size: 34070 x: 341 y:400 [1] size: 36155 x: 345 y:400 [3] size: 34242 x: 345 y:400 [4] size: 30914 x: 341 y:400 [2] size: 35022 x: 345 y:400 [1] size: 35794 x: 345 y:400 [3] size: 31943 x: 344 y:400 [4] size: 37375 x: 344 y:400 [2] size: 39989 x: 345 y:400 [1] size: 31005 x: 345 y:400 [3] size: 27808 x: 345 y:400 [4] size: 35477 x: 341 y:400 [2] size: 42335 x: 344 y:400 [1] size: 28935 x: 345 y:400 [3] size: 36160 x: 345 y:400 [4] size: 35398 x: 341 y:400 [1] size: 39711 x: 345 y:400 [3] size: 34969 x: 345 y:400 [2] size: 33664 x: 345 y:400 [4] size: 35818 x: 345 y:400

With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.

RIP Neil Armstrong


In reply to Re^8: removing all threads.. by BrowserUk
in thread removing all threads.. by ISAI student

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 musing on the Monastery: (2)
As of 2024-03-19 06:57 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found