Code Comments

Programming Forum and web based access to our favorite programming groups.
For Programmers: Free Programming Magazines | New: Database administration forum
Registration is free! Edit your profileCalendarFind other membersFrequently Asked QuestionsSearch -> 
Post New Thread











Thread
Author

GD not working
I cannot make GD (graphics or GIF display) to produce any kind of
graphics from Perl. I cannot find the solution from the previous
postings in this newgroup or anywhere else on the net, but others seem
to have similar problems. So a rather lengthy description of the
problem. Apologies in advance !!!

I installed Perl 5.8.4.810 from ActiveState (a couple of times). It
works very well in our Windows XP/administrator setup. Except when
printing graphs on data.

From the Perl Cookbook we got the idea of installing GD. The code
starts out

use GD::Graph::lines; ...

Started out by downloading from http://www.boutell.com/gd/ the windows
DLL (.zip) file. This extracts, but does not add any immediate support
for GD... because Perl complains that INC cannot see GD. Also the
bgd.dll and a few exe files does not seem to belong anywhere - except
in the newly extracted folder. Tried to copy these files to windows
and perl binary folders, but off course no action. Still, all the talk
about linking seemed to be for C-programmers and/or UNIX users. There
must be a way ...

Also some talk about libpng and zlib. Same argument, the necessary
code is hopefully available somewhere to copy or install.

In the boutell doc was the message: gd can also be used from Perl,
courtesy of Lincoln Stein's GD.pm library
(http://stein.cshl.org/WWW/software/GD/). Downloaded that zip info.

Here was a piece of (perl) code, starting out with
use GD;
# create a new image
$im = new GD::Image(100,100);
..
which would produce a graphic image of a red circle. Extracted the new
zip-file, which should be ppm'ed to install. This did not work as the
'GD.PPD could not be found'. But on this group was a mention of a
working ppd, namely

ppm install http://theoryx5.uwinnipeg.ca/ppms/GD.ppd

which had a correct PPD and completed. PPM has acknowledged a version
1.27.2 is installed. And now the above mentioned "use GD;" in the perl
script is passed wihtout any problems. Unfortunately the last lines of
the example is
..
# And fill it with red
$im->fill(50,50,$red);
# make sure we are writing to a binary stream
binmode STDOUT;
# Convert the image to PNG and print it on standard output
print $im->png;

Nothing happens, except for some nonsense characters being displayed
and the bell sounds a few times. Anybody has any idea ?

Report this thread to moderator Post Follow-up to this message
Old Post
peter
09-14-04 01:55 AM


Re: GD not working
On 13 Sep 2004 13:52:39 -0700,
peter <pgs@asia.com> wrote:

[snip very lengthy discussion about a problem that was solved, I
think]

>   use GD;
>   # create a new image
>   $im = new GD::Image(100,100);

I prefer

my $im = GD::Image->new(100, 100);

You definitely need to start using strictures (and therefore the my),
and I simply don't like the indirect method invocation you use.

[snip]

>    # And fill it with red
>    $im->fill(50,50,$red);
>    # make sure we are writing to a binary stream
>    binmode STDOUT;
>    # Convert the image to PNG and print it on standard output
>    print $im->png;
>
> Nothing happens, except for some nonsense characters being displayed
> and the bell sounds a few times. Anybody has any idea ?

Not nonsense characters. That is your PNG image data being printed to
the standard output channel of your application, just like you
requested.  All you need to do is capture it in a file by using your
shell's redirection. If you don't want to do that (or don't know how
to), then do something like (warning: untested code):

open my $fh, ">", "output.png"
or die "Cannot open output.png for write: $!";
binmode $fh;
print $fh $im->png;
close $fh;

Martien
--
|
Martien Verbruggen      | That's funny, that plane's dustin' crops
Trading Post Australia  | where there ain't no crops.
|

Report this thread to moderator Post Follow-up to this message
Old Post
Martien Verbruggen
09-14-04 01:55 AM


Re: GD not working
Thanks Martien, so close and yet so far off. So it works, thanks
again! Not to waste your time, but: Do you know of a simple way to
constantly display the updated png's (kind of like an animation) ?


> open my $fh, ">", "output.png"
>     or die "Cannot open output.png for write: $!";
> binmode $fh;
> print $fh $im->png;
> close $fh;
>
> Martien

Report this thread to moderator Post Follow-up to this message
Old Post
peter
09-14-04 01:57 PM


Re: GD not working
On 14 Sep 2004 01:18:27 -0700,
peter <pgs@asia.com> wrote: 
> Thanks Martien, so close and yet so far off. So it works, thanks
> again! Not to waste your time, but: Do you know of a simple way to
> constantly display the updated png's (kind of like an animation) ?

PNG is only a single frame format, so you can't create animations with
it. The MNG format would be more appropriate. You should be able to
take a series of PNG images, and use Image::Magick to make an MNG
animation.

If you're asking how you can have a web/HTTP URL that automatically
updates an image, you should probably ask that in a group that talks
about HTTP protocol issues, or maybe CGI. You could simply send the
appropriate header to the client that asks it to reload the image
after a certain time interval, or you probably can do something with
NPH (non-parsed-header) programming techniques int hat area. One of
the groups in the comp.infosystems.www.* hierarchy is probably a good
place to ask.

Martien
--
|
Martien Verbruggen      | There are only 10 types of people in the
Trading Post Australia  | world; those who understand binary and those
| who don't.

Report this thread to moderator Post Follow-up to this message
Old Post
Martien Verbruggen
09-15-04 08:57 AM


Re: GD not working
Thanks Martien, so close and yet so far off. So it works, thanks
again! Not to waste your time, but: Do you know of a simple way to
constantly display the updated png's (kind of like an animation) ?


> open my $fh, ">", "output.png"
>     or die "Cannot open output.png for write: $!";
> binmode $fh;
> print $fh $im->png;
> close $fh;
>
> Martien

Report this thread to moderator Post Follow-up to this message
Old Post
peter
09-17-04 01:31 AM


Re: GD not working
On 14 Sep 2004 01:18:27 -0700,
peter <pgs@asia.com> wrote: 
> Thanks Martien, so close and yet so far off. So it works, thanks
> again! Not to waste your time, but: Do you know of a simple way to
> constantly display the updated png's (kind of like an animation) ?

PNG is only a single frame format, so you can't create animations with
it. The MNG format would be more appropriate. You should be able to
take a series of PNG images, and use Image::Magick to make an MNG
animation.

If you're asking how you can have a web/HTTP URL that automatically
updates an image, you should probably ask that in a group that talks
about HTTP protocol issues, or maybe CGI. You could simply send the
appropriate header to the client that asks it to reload the image
after a certain time interval, or you probably can do something with
NPH (non-parsed-header) programming techniques int hat area. One of
the groups in the comp.infosystems.www.* hierarchy is probably a good
place to ask.

Martien
--
|
Martien Verbruggen      | There are only 10 types of people in the
Trading Post Australia  | world; those who understand binary and those
| who don't.

Report this thread to moderator Post Follow-up to this message
Old Post
Martien Verbruggen
09-19-04 08:55 AM


Sponsored Links




Last Thread Next Thread Next
Search this forum -> 
Post New Thread

PERL Modules archive

Show a Printable Version Send to friend Email This Page to Someone! subscribe to this thread Receive updates to this thread
Computer Consultants
Programming Jobs
Visual Basic Controls
SQL Server Programming
Webservices
Java Security
Visual Studio
C# Programming
Visual J++
Software engineering
Open source Software
Perl Programming
PHP Programming
ASP Programming
ASP .NET Programming
Visual Basic Programming
Windows Scripting Host
Java Programming
Java Help
Java Beans
VBScript
Cobol
MAC Applications
Unix Programming
Forum Jump:
All times are GMT. The time now is 05:13 PM.

 
Free MCSE Braindumps | Real Estate Topics

Programming forum archive

Copyrights CodeComments.com 2004 - 2006

Powered by vBulletin Copyright 2000-2006 Jelsoft Enterprises Limited.