SPUG: GD file save

Steve Laybourn otter101 at hotmail.com
Tue Jan 4 17:48:44 CST 2000

   I, too, am interested in this very problem...

>Dear Perl Gurus...
>I used the GD graphic module with success on a couple of projects last
>year to create charts from live data and then both display it directly
>and save the GD generated image to a file. That was accomplished on an
>NT system.
>I changed over my server to Linux last September and have had excellent
>results with the exception of this strange GD problem...I cannot get
>the GD module to save the created image to a file on the hard drive.
>Following lines are based on instructions with the GD module...
>    	###print to screen  -- this works
>    	binmode (STDOUT);
>    	print $im->gif;
>	####write to file -- from my NT module docs, works on NT
>	$imgfile = 'testsave.gif';
>	$im->gif($imgfile);
>	####write to file -- from Linux module docs, does not work
>	$gif_data = $im->gif;
>	open (MYFILE,">testsave.gif") || die;

---I'm not exactly sure, but I'm wondering if the +> option needs to be set 
for this file opening statement so's to clear the previous contents before 
   And perhaps:

flock(MYFILE,2); #lock the file while in use

   could be used too. I'd always learned that it was a good idea to practice 
file locking whenever possible. But that could be more for databases in 
which a real risk of data collision could occur...

>	binmode MYFILE;
>	print MYFILE $gif_data;
>	close DISPLAY;

--- close DISPLAY? (oops, wrong filehandle) Perhaps:

flock(MYFILE,8); #We're done writing data, unlock the file
close MYFILE;

   Hmmm, I'd be interested in how you can get CPAN modules installed on NT 
in the first place...this is easily the most stubborn system I've ever 
worked on...
   Good luck, sir!
   Be seeing you,
   Steve Laybourn
Get Your Private, Free Email at http://www.hotmail.com

 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    POST TO: spug-list at pm.org        PROBLEMS: owner-spug-list at pm.org
 Seattle Perl Users Group (SPUG) Home Page: http://www.halcyon.com/spug/
 SUBSCRIBE/UNSUBSCRIBE: Replace ACTION below by subscribe or unsubscribe
        Email to majordomo at pm.org: ACTION spug-list your_address

More information about the spug-list mailing list