perl - Why is this script creating a corrupted PNG file on Windows? -



perl - Why is this script creating a corrupted PNG file on Windows? -

i trying create png file.

the script below executes without returning errors, output file tester.png cannot viewed (and cmd window prints attached attached text).

i not sure why cannot view png file produced script.

i have used both active perl (5.18.2) , strawberry perl (5.18.4.1) same problem. tried strawberry perl has libgd , libpng part of installation, though i'm not getting errors. advice?

#!/usr/bin/perl utilize bio::graphics; utilize bio::seqfeature::generic; utilize strict; utilize warnings; $infile = "data1.txt"; open( align, "$infile" ) or die; $outputfile = "tester.png"; open( outfile, ">$outputfile" ) or die; $panel = bio::graphics::panel->new( -length => 1000, -width => 800 ); $track = $panel->add_track( -glyph => 'generic', -label => 1 ); while (<align>) { # read blast file chomp; #next if /^\#/; # ignore comments ( $name, $score, $start, $end ) = split /\t+/; $feature = bio::seqfeature::generic->new( -display_name => $name, -score => $score, -start => $start, -end => $end ); $track->add_feature($feature); } binmode stdout; print $panel->png; print outfile $panel->png;

you have

binmode stdout; print $panel->png;

interestingly, have:

print outfile $panel->png;

but never binmode outfile. so, display contents of png file in command prompt, , create corrupt png file. (see when bits don't stick.)

if remove print outfile ..., , redirect output of script png file, should able view contents in image viewer.

c:\> perl myscript.pl > panel.png

alternatively, can avoid printing contents of binary file console window, , instead use

binmode outfile; print $panel->png;

perl png bioperl

Comments

Popular posts from this blog

java - How to set log4j.defaultInitOverride property to false in jboss server 6 -

c - GStreamer 1.0 1.4.5 RTSP Example Server sends 503 Service unavailable -

Using ajax with sonata admin list view pagination -