Gossamer Forum
Quote Reply
PNG Again.
Hi,

I can't seem to create any images on the fly, if they are PNG or Gif. I have GD.pm installed, as well as PNGgraph
PNGgraph::area
PNGgraph::axestype
PNGgraph::bars
PNGgraph::colour
PNGgraph::lines
PNGgraph::linespoints
PNGgraph::mixed
PNGgraph::pie
PNGgraph::points
PNGgraph::utils

Here is the code I am using...

Code:
#!/usr/bin/perl
# Load Required Modules.
use CGI;
my $in = new CGI;
use CGI::Carp qw/fatalsToBrowser/;
use GD;

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

# allocate some colors
$white = $im->colorAllocate(255,255,255);
$black = $im->colorAllocate(0,0,0);
$red = $im->colorAllocate(255,0,0);
$blue = $im->colorAllocate(0,0,255);

# make the background transparent and interlaced

$im->interlaced('true');

# Put a black frame around the picture
$im->rectangle(0,0,99,99,$black);

# Draw a blue oval
$im->arc(50,50,95,75,0,360,$blue);

# 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;

Can you see anything that might be wrong there? I am thinking my host setup the Modules wrong - but just incase its me... Smile

If anyone has a ready made script that I can upload and set to 755 to see if it works? Thanks!

------------------
Michael Bray
Review your webhost or find a new one.
www.webhostarea.com
Links SQL User
------------------




Quote Reply
Re: PNG Again. In reply to
Have you tried running any of the test scripts? I think the module came with some, to show off the features.

If the test scripts run, then it all works. If not, then you have a place to start. Either way, you should have some sample code.

Hey! One program that makes _extensive_ use of the GD.pm module is the HamWeather program -- It's free, It's well written, and should help give you some ideas.

To see what the program is capable of, check out their site hamweather.com or check out my site postcards.com and click the WeatherCards link.



------------------
POSTCARDS.COM -- Everything Postcards on the Internet www.postcards.com
LinkSQL FAQ: www.postcards.com/FAQ/LinkSQL/








Quote Reply
Re: PNG Again. In reply to
I didn't know it came with any test scripts. This is on a Virtual server (webhostarea is on this server...)so I don't have root access to install modules, therefore I was not aware it came with test scripts.

How would I access them? I read the perldocs, and thats how I came up with the code above (which I think should work Smile).

Thanks!

------------------
Michael Bray
Review your webhost or find a new one.
www.webhostarea.com
Links SQL User
------------------




Quote Reply
Re: PNG Again. In reply to
Check at www.perl.org in the modules directory, and you'll find where you can download the GD.pm.

download it, untar it, and you can get the scripts.

That's also the best way to get the docs on most of the installed modules -- like DBI and LWP.



------------------
POSTCARDS.COM -- Everything Postcards on the Internet www.postcards.com
LinkSQL FAQ: www.postcards.com/FAQ/LinkSQL/








Quote Reply
Re: PNG Again. In reply to
The problems with my host,

I just got an email from them saying that won't install modules for me cause they use to much system resources and if I need more modules I'll need a dedicated server.

A dedicateds server for Webhost Area seems like a waste of money to me... I donno - pissed off at the moment. I am sure GD.pm won't slow down the bloody server Smile

Anyways - Time to start shopping around - RIght now Virtualis and Burst.net are looking good Smile



------------------
Michael Bray
Review your webhost or find a new one.
www.webhostarea.com
Links SQL User
------------------




Quote Reply
Re: PNG Again. In reply to
I know,

Text is nothing for todays processors, and with the 1.5Ghz Processor announced today - Graphics won't be Smile

I am thinking of getting a $195 a month dedicated server - which gives me a PII 400 with 128MB Ram - Only 6GB Transfer - But that seems to be getting cheaper, so I can upgrade when needed.

Right now I am still deciding whether or not its worth it for a hobby Frown - $700 is too much for a hobby!

I have gotten about 10 emails from hosts offering a free Virtual server, maybe I'll wait till I get offered a free Dedicated one Smile

------------------
Michael Bray
Review your webhost or find a new one.
www.webhostarea.com
Links SQL User
------------------




Quote Reply
Re: PNG Again. In reply to
Actually, GD.pm does use a fair amount of resources... but you _can_ install it locally <G>.... Don't push your ISP though. Image generation is one of the most computer intensive things you can do -- it's basically tightly compacted number crunching.

(My first 10-15 years in computers was all image generation. I remember how excited I was with my first 386 at it's raw SPEED!!! Today I generate files that couldn't even have been processed by those machines!)

Graphics have driven the development of memory, CPU and peripherals more than any other single thing in computers. Without graphics, hardware is completely adaquate for the tasks we expect of it ... the graphics processing in all phases is what eats into the capability.

Scripts/dynamic generation is very resource intensive, then add to it a calculation process like image processing, and when an ISP tries to spread it around to an over-subscribed list of customers, they target the one or two high-end users and then all the lower-end users seem to think things got better --- AOL, DELPHI, CompuServe, Prodigy, etc all did that at one time or another as well. Trim the top 5 or 10% and you suddenly look better, and can even be more profitable.

Anyway... a Links site needs more horsepower, and less physical resources (disk/bandwidth) than most sites. Most ISP's are concentrating on bandwidth and harddrive space (since it's actually cheaper than CPU). A links site needs to look at the CPU and RAM, then bandwidth. It also needs to look at what shared processes are running on a shared server -- that's why a dedicated server is often the only way to go. A small CGI site needs it's own server at a much lower traffic level than a static site. ISP's are just not set up to offer this. It means fewer customers per machine, and thus higher costs.

This is the basis for the hosting plan I've been working on. By pooling resources into a "group" the bandwidth will take care of itself, while each site remains responsible for the CPU it consumes. With a shared high-end database server back end, the front-end computers could be reasonably powered machines, not awesome iron.

Any host that allows CGI then gets a reputation for it, will be swamped and either will raise prices, or cut service. It's a fact of life. The price point is about $350/month for CPU and about $350/month CoLocation/Bandwidith. If you do both at the same time, you can get about 20% better. Below that, you are using "excess capacity" resources that the ISP is eventually going to want to sell, not give away.

"Free" sites are ignoring the concept of "No such thing as a free lunch." SOMEONE is paying... and eventually it will be you, or you'll be shut down. (not to you personally, Michael).

But if your site requires $400/month in resources to keep alive, there is no way you can get it for $50/month unless someone else is paying -- for some sites, it's advertising. But _NO_ site on a free host using cgi like Links is generating $400/month+ in advertising revenues for them.

So, they will shut those sites down first.

A site with static pages, 20 meg of disk space, and 50 meg of traffic a month (don't laugh!) can actually make them money if each access is an advertising display on a targeted site. Some sites don't even do that much traffic -- and they are PROFITABLE because they are "content" for the host, and consume no resources -- any page access is a page-view for their advertising.

CGI consumes INVISIBLE resources... so it has to have a HIGH rate of return on the visible portions.










------------------
POSTCARDS.COM -- Everything Postcards on the Internet www.postcards.com
LinkSQL FAQ: www.postcards.com/FAQ/LinkSQL/