473,395 Members | 1,688 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Image_Graph Problem

Hello All,

I am having a problem with Image_Graph on php 5.1.4. I installed the package
and all of its dependencies through pear installer without any hitches. Then
I started to add some very simple code to create a graph in an existing php
page. I added the code for the graph and added the elements of it plus some
static data. However, when I browse the page, I get garbled data instead of
the graph. Has anyone ever run into this problem. I am testing this on an xp
test bed for now.

I am thinking the fact that I'm getting garbled data means that the class
creation has gone well; however rendering the graph is not happening for
some reason.

Jul 17 '06 #1
5 3011
On Mon, 17 Jul 2006 19:34:59 GMT, Shawn Hamzee <ha****@sbcglobal.net.INVALID>
wrote:
>I am having a problem with Image_Graph on php 5.1.4. I installed the package
and all of its dependencies through pear installer without any hitches. Then
I started to add some very simple code to create a graph in an existing php
page. I added the code for the graph and added the elements of it plus some
static data. However, when I browse the page, I get garbled data instead of
the graph. Has anyone ever run into this problem. I am testing this on an xp
test bed for now.

I am thinking the fact that I'm getting garbled data means that the class
creation has gone well; however rendering the graph is not happening for
some reason.
Have you output an appropriate Content-type header for the image format you're
using?

--
Andy Hassall :: an**@andyh.co.uk :: http://www.andyh.co.uk
http://www.andyhsoftware.co.uk/space :: disk and FTP usage analysis tool
Jul 17 '06 #2

Actually, I just found out what is going on:
In order to use image_graph, one cannot have both a graph and html (php
generated or otherwise) on the same page.

So in order to get around this, you'll have to save the graph to an image
file (.png) and then echo a link in the script for it.

Thanks.

On 7/17/06 15:51, in article di********************************@4ax.com,
"Andy Hassall" <an**@andyh.co.ukwrote:
On Mon, 17 Jul 2006 19:34:59 GMT, Shawn Hamzee <ha****@sbcglobal.net.INVALID>
wrote:
>I am having a problem with Image_Graph on php 5.1.4. I installed the package
and all of its dependencies through pear installer without any hitches. Then
I started to add some very simple code to create a graph in an existing php
page. I added the code for the graph and added the elements of it plus some
static data. However, when I browse the page, I get garbled data instead of
the graph. Has anyone ever run into this problem. I am testing this on an xp
test bed for now.

I am thinking the fact that I'm getting garbled data means that the class
creation has gone well; however rendering the graph is not happening for
some reason.

Have you output an appropriate Content-type header for the image format
you're
using?
Jul 17 '06 #3
Rik
Shawn Hamzee wrote:

Don't toppost
<an**@andyh.co.ukwrote:
><ha****@sbcglobal.net.INVALIDwrote:
>>I am having a problem with Image_Graph on php 5.1.4. I installed
the package and all of its dependencies through pear installer
without any hitches. Then I started to add some very simple code to
create a graph in an existing php page. I added the code for the
graph and added the elements of it plus some static data. However,
when I browse the page, I get garbled data instead of the graph.
Has anyone ever run into this problem. I am testing this on an xp
test bed for now.

I am thinking the fact that I'm getting garbled data means that the
class creation has gone well; however rendering the graph is not
happening for some reason.

Have you output an appropriate Content-type header for the image
format you're
using?
Actually, I just found out what is going on:
In order to use image_graph, one cannot have both a graph and html
(php generated or otherwise) on the same page.

So in order to get around this, you'll have to save the graph to an
image
file (.png) and then echo a link in the script for it.
Not really.
You could save the portion of your script that makes the graph something
like graphcreator.php, and echo that as the source for your image. That way
it will always stay up to date without any constant diskwriting. Depending
on how much people will see the graph storing it and refreshing it
periodically could save some overhead. If it's just some statistics a few
people will check out a couple of times per week I'd keep it totally
dynamic.

Grtz,
--
Rik Wasmus
Jul 17 '06 #4
Shawn Hamzee wrote:
>
Don't toppost
><an**@andyh.co.ukwrote:
>><ha****@sbcglobal.net.INVALIDwrote:
I am having a problem with Image_Graph on php 5.1.4. I installed
the package and all of its dependencies through pear installer
without any hitches. Then I started to add some very simple code to
create a graph in an existing php page. I added the code for the
graph and added the elements of it plus some static data. However,
when I browse the page, I get garbled data instead of the graph.
Has anyone ever run into this problem. I am testing this on an xp
test bed for now.

I am thinking the fact that I'm getting garbled data means that the
class creation has gone well; however rendering the graph is not
happening for some reason.

Have you output an appropriate Content-type header for the image
format you're
using?
Actually, I just found out what is going on:
In order to use image_graph, one cannot have both a graph and html
(php generated or otherwise) on the same page.

So in order to get around this, you'll have to save the graph to an
image
file (.png) and then echo a link in the script for it.

Not really.
You could save the portion of your script that makes the graph something
like graphcreator.php, and echo that as the source for your image. That way
it will always stay up to date without any constant diskwriting. Depending
on how much people will see the graph storing it and refreshing it
periodically could save some overhead. If it's just some statistics a few
people will check out a couple of times per week I'd keep it totally
dynamic.

Grtz,
Really! Do you have a working example of your method? I'd be interested to
see how the source of image can be a php file!

Thanks

Jul 17 '06 #5
Rik
Shawn Hamzee wrote:
>Shawn Hamzee wrote:

Don't toppost
>><an**@andyh.co.ukwrote:
<ha****@sbcglobal.net.INVALIDwrote:
I am having a problem with Image_Graph on php 5.1.4. I installed
the package and all of its dependencies through pear installer
without any hitches. Then I started to add some very simple code
to create a graph in an existing php page. I added the code for
the
graph and added the elements of it plus some static data. However,
when I browse the page, I get garbled data instead of the graph.
Has anyone ever run into this problem. I am testing this on an xp
test bed for now.
>
I am thinking the fact that I'm getting garbled data means that
the class creation has gone well; however rendering the graph is
not happening for some reason.

Have you output an appropriate Content-type header for the image
format you're
using?
Actually, I just found out what is going on:
In order to use image_graph, one cannot have both a graph and html
(php generated or otherwise) on the same page.

So in order to get around this, you'll have to save the graph to an
image
file (.png) and then echo a link in the script for it.

Not really.
You could save the portion of your script that makes the graph
something like graphcreator.php, and echo that as the source for
your image. That way it will always stay up to date without any
constant diskwriting. Depending on how much people will see the
graph storing it and refreshing it periodically could save some
overhead. If it's just some statistics a few people will check out a
couple of times per week I'd keep it totally dynamic.

Grtz,

Really! Do you have a working example of your method? I'd be
interested to see how the source of image can be a php file!

Not from the graph, but kind of a mirror effect with fade i recently worked
on:
(NOTE: by no means a finished product, it has some bugs in it!){
<?php
function transborder($image,$width,$red,$green,$blue){
$size = @getimagesize($image);
if($size===false) return false;
switch($size[2]){
case 1:
$image = imagecreatefromgif($image);
break;
case 2:
$image = imagecreatefromjpeg($image);
break;
case 3;
$image = imagecreatefrompng($image);
break;
default:
return false;
}
$x = $size[0];
$y = $size[1];

$new = imagecreatetruecolor($x, $y + $width - 1);
$back = imagecolorallocate($new,$red,$green,$blue);
imagefill($new,0,0,$back);
imagecopyresampled($new,$image,0,0,0,0,$x,$y,$x,$y );
for($i=1;$i<=$width;$i++){
imagecopyresampled($new,$image,0,$y+$i-1,0,$y-$i,$x,1,$x,1);
}
imagealphablending($new,true);
for($i=0;$i < $width;$i++){
//$trans = floor(0.03125 * $i * $i);
$trans = $i *2;
$color = imagecolorallocatealpha($new,$red,$green,$blue,$tr ans);
imageline($new,0,$y+$width-$i,$x,$y+$width-$i,$color);
}
header("Content-type: image/png");
imagepng($new);
imagedestroy($image);
imagedestroy($new);
}

/* now we can call the function with the following arguments:
string imagelocation (local or url)
int width mirrored surface
int red
int green
int blue*/

transborder('http://nl3.php.net/images/php.gif',50,255,240,240);
?>
The magic happens here:
header("Content-type: image/png");
imagepng($new);

Send the right header, and imagepng() (or imagejpeg() or imagegif()) will
output it directly. And never, ever, forget to imagedestroy() you images...
A good tip was to register a shutdown function:

function shutdown_func() {
global $image,$new;
if($img) imagedestroy($img);
if($new) imagedestroy($new);
}
register_shutdown_function("shutdown_func");

Allthough this does take an existing image, it creates a totally new one.
Creating an image with imagefilledpolygon(), imageline() and the like is
also possible. with those kind of functions the graph is actually made.

Check out the extensive GD library, a lot is possible (and even more
impossible unfortunately :-)

Grtz,
--
Rik Wasmus
Jul 17 '06 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Greg Bryant | last post by:
I'm a bit confused about image_graph - I'm just trying to create a line graph with multiple lines, be able to assign the text for the x and y ticks and colors for the lines. A legend would be...
117
by: Peter Olcott | last post by:
www.halting-problem.com
28
by: Jon Davis | last post by:
If I have a class with a virtual method, and a child class that overrides the virtual method, and then I create an instance of the child class AS A base class... BaseClass bc = new ChildClass();...
6
by: Ammar | last post by:
Dear All, I'm facing a small problem. I have a portal web site, that contains articles, for each article, the end user can send a comment about the article. The problem is: I the comment length...
0
by: Lorenzo Thurman | last post by:
I need to use it to produce presentation graphics. I'm still working my way through the docs, but could use some assistance with the following: I need a way to have Image_Graph output graphs via a...
2
by: Lorenzo Thurman | last post by:
I keep getting this error when trying to use fonts with Image_Graph: PHP Fatal error: Call to undefined function: imagettfbbox() in /usr/local/lib/php/Image/Canvas/GD.php on line 1240 After...
0
by: Lorenzo Thurman | last post by:
How do I tell Image_Graph(or Freetype) where to look for fonts? They were installed under /usr/local/, but I still get an error when calling a font. I can hard code the path to the font, so it...
0
by: Lorenzo Thurman | last post by:
I didn't get any replies the first time, so I'm trying again: How do I tell Image_Graph(or Freetype) where to look for fonts? They were installed under /usr/local/, but I still get an error when...
3
by: goldreads | last post by:
Hey guys, I've been putting together a line graph in Image_Graph. And I can't seem to find an answer to change the layout of few things. Here is my graph: http://www.goldreads.com/test.png ...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.