Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?

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]
[LanX]: Yeah option a doesn't go into history
[LanX]: probably I need to teach the app to restart after C-c Kill
[Corion]: LanX: Maybe have an infinite-loop cmd file? Much easier than trying to manage that from within Perl IMO
[Corion]: Alternatively, relaunch the application from cron (or a Windows cron) every minute
[LanX]: will try infinite loop ...
[Corion]: :START ... goto START
[LanX]: oh .bat you mean?
[LanX]: obscure cult ...
[Corion]: LanX: cmd.exe is just another way to launch Perl

How do I use this? | Other CB clients
Other Users?
Others taking refuge in the Monastery: (13)
As of 2017-03-27 15:54 GMT
Find Nodes?
    Voting Booth?
    Should Pluto Get Its Planethood Back?

    Results (320 votes). Check out past polls.