illtud has asked for the wisdom of the Perl Monks concerning the following question:
I've read the buffering FAQs and I've peppered my code with '$| = 1;'and STDOUT->flush(); , tried STDOUT->autoflush(1); but since moving from a RHEL5 (perl 5.8.8) to RHEL6 (perl 5.10.1) this script (simplified from original, but still exhibits the problem) doesn't write out all the binary image data to STDOUT before the last line is written - the last line appears in the middle of the binary data about 150 bytes from the end.
Help!
ImageMagick-perl has gone from ImageMagick-perl-6.2.8.0-15.el5_8 to ImageMagick-perl-6.5.4.7-6.el6_2.x86_64
#!/usr/bin/perl use warnings; use Getopt::Long; use Image::Magick; use IO::Handle qw( ); $| = 1; STDOUT->autoflush(1); # Mandatory options: # -f photo jpeg file (full path) GetOptions ( 'f=s' => \$photofile) or die ("can't do getops\n"); #Open the image as an Perlmagick object $ffoto = new Image::Magick; $x = $ffoto->Read($photofile); warn "can't open photofile:$x" if "$x"; $ffoto->Resize(geometry=>'x296'); $ffoto->Set(depth=>8); $ffoto->Rotate(degrees=>270); $ffoto->Negate(); $ffoto->Evaluate(value=>8, operator=>'Divide'); #Copy image to new image objects $yellow = $ffoto->Clone(); #Separate the colours - need to set depth again $yellow->Separate(channel=>'yellow'); $yellow->Set(depth=>8); ## ## EPCL output section ## #yellow: binmode STDOUT; $yellow->Write('gray:-'); print ("\r"); print ("\x1bIS 0\r"); #DEBUG print ("should be last line\n"); exit 0;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: STDOUT buffering problem
by hdb (Monsignor) on Apr 16, 2013 at 12:52 UTC | |
|
Re: STDOUT buffering problem
by RichardK (Parson) on Apr 16, 2013 at 12:55 UTC | |
by illtud (Initiate) on Apr 16, 2013 at 13:17 UTC | |
|
Re: STDOUT buffering problem
by choroba (Cardinal) on Apr 16, 2013 at 13:52 UTC | |
by illtud (Initiate) on Apr 16, 2013 at 14:46 UTC | |
|
Re: STDOUT buffering problem
by Khen1950fx (Canon) on Apr 16, 2013 at 16:46 UTC | |
by illtud (Initiate) on Apr 17, 2013 at 14:55 UTC | |
|
Re: STDOUT buffering problem
by CountOrlok (Friar) on Apr 16, 2013 at 14:02 UTC | |
by illtud (Initiate) on Apr 16, 2013 at 14:47 UTC | |
by illtud (Initiate) on Apr 16, 2013 at 16:43 UTC | |
|
Re: STDOUT buffering problem
by Anonymous Monk on Apr 17, 2013 at 02:30 UTC | |
by illtud (Initiate) on Apr 17, 2013 at 14:57 UTC |