Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask

Re: STDOUT buffering problem

by CountOrlok (Friar)
on Apr 16, 2013 at 14:02 UTC ( #1028921=note: print w/replies, xml ) Need Help??

in reply to STDOUT buffering problem

This may be a longshot, but I wonder if the $yellow->Write() writes to stdout in a separate thread (in the imageMagick library) and so your print statements are disjoint from the Write. One of the imageMagick forums mentioned setting the environment variable MAGICK_THREAD_LIMIT to 1. Could be that may help.

Replies are listed 'Best First'.
Re^2: STDOUT buffering problem
by illtud (Initiate) on Apr 16, 2013 at 14:47 UTC
    MAGICK_THREAD_LIMIT to 1. Could be that may help.

    Good idea! Nope, no different. Setting to 0 doesn't help either.

      OK, for a quick fix I rewrote it to output the image data to temporary files (in the full script there's an image for each of the CMY layers) and then write those out to stdout.

      I couldn't work out from Image::Magick how to get the binary data out using GetPixels to match the binary data that I got from writing out the files, at some point I'll go and ask the ImageMagick list and that will let me do without the temporary files.

      Thanks for your replies, this one was a puzzler to me, but I'm no perl guru! This is a snippet of what worked for me:

      ... binmode STDOUT; $yellow->Write('gray:/tmp/yellow'); open(FIN,"</tmp/yellow") || die("cannot access file /tmp/yellow\n"); while (sysread FIN, $buffer, 4096) { print $buffer; } close FIN; print("\r"); ...

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1028921]
[Corion]: Hmmm. Maybe I can still fake the one spot where I want/need a window function in SQLite... I think I'm never really interested in the real "next" image (not hidden/deleted)

How do I use this? | Other CB clients
Other Users?
Others avoiding work at the Monastery: (6)
As of 2018-03-23 17:53 GMT
Find Nodes?
    Voting Booth?
    When I think of a mole I think of:

    Results (295 votes). Check out past polls.