Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

Hi All,
I generate a *jpeg* graphic and save it in a file in the /tmp directory of one of the servers I've been using. I then open() the file, do a bin mode, and read each line of the file. When I display the returned image in ifranview, (a very good image viewer), the image displays properly. *However*, when I save the file and attempt to display it in internet explorer 5.0+, the microsoft icon spins but never displays the content. Any idea on what is happening?

Thanks

PS. Note: This may be a repost... I thought I posted a question about it, but it appears I might not have submitted it since it's not appearing on new nodes...

Replies are listed 'Best First'.
Re: gd and internet explorer
by Cabrion (Friar) on Feb 11, 2003 at 17:15 UTC
    You probably don't need binmode unless your script is running in Windows. I doubt it is because you referenced /tmp. If that is the case, comment out the binmode lines below. When working with binary files, use read() to have better control over memory usage.

    open (IN, "<$path/$filename.tmp") || die $!; binmode IN; open (OUT, ">$path/$filename.jpg") || die $!; binmode OUT; print OUT $buf while read IN, $buf, 8192; close IN; close OUT;
    P.S.
    If you are transfering that file via FTP from the server to the windows box to test opening it . . you did remeber to set FTP to binary more by issuing "bin" before the get right?

      If the file is binary you should binmode() no matter where you run. Think about porting the script!

      Plus with the advent of LAYERs in Perl 5.8 binmode() stops being a NOOP under Unix and you may actually HAVE to use binmode() even if you are running a unix.

      Jenda

      This is a web page app, not a ftp app... I think I have one more thing up my sleve... (perhaps an img tag will get it to work, because I *was* able to get that to work the last time I generated an image... ) thanks for the tid bits anyways... very strange behavior
Re: gd and internet explorer
by zakzebrowski (Curate) on Feb 13, 2003 at 12:09 UTC
    strange. you can trick gd into working right by instead of directly returning the image to the client, generate a web page that uses an IMG link to that newly generated image, and that will work.

    ----
    Zak
    Pluralitas non est ponenda sine neccesitate - mysql's philosphy