473,792 Members | 3,251 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 3041
On Mon, 17 Jul 2006 19:34:59 GMT, Shawn Hamzee <ha****@sbcglob al.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.u k :: 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****@sbcglob al.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****@sbcglo bal.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?
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.ph p, 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****@sbcgl obal.net.INVALI Dwrote:
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.ph p, 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.c o.ukwrote:
<ha****@sbcg lobal.net.INVAL IDwrote:
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.ph p, 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($im age,$width,$red ,$green,$blue){
$size = @getimagesize($ image);
if($size===fals e) return false;
switch($size[2]){
case 1:
$image = imagecreatefrom gif($image);
break;
case 2:
$image = imagecreatefrom jpeg($image);
break;
case 3;
$image = imagecreatefrom png($image);
break;
default:
return false;
}
$x = $size[0];
$y = $size[1];

$new = imagecreatetrue color($x, $y + $width - 1);
$back = imagecoloralloc ate($new,$red,$ green,$blue);
imagefill($new, 0,0,$back);
imagecopyresamp led($new,$image ,0,0,0,0,$x,$y, $x,$y);
for($i=1;$i<=$w idth;$i++){
imagecopyresamp led($new,$image ,0,$y+$i-1,0,$y-$i,$x,1,$x,1);
}
imagealphablend ing($new,true);
for($i=0;$i < $width;$i++){
//$trans = floor(0.03125 * $i * $i);
$trans = $i *2;
$color = imagecoloralloc atealpha($new,$ red,$green,$blu e,$trans);
imageline($new, 0,$y+$width-$i,$x,$y+$width-$i,$color);
}
header("Content-type: image/png");
imagepng($new);
imagedestroy($i mage);
imagedestroy($n ew);
}

/* 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('ht tp://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($i mg);
if($new) imagedestroy($n ew);
}
register_shutdo wn_function("sh utdown_func");

Allthough this does take an existing image, it creates a totally new one.
Creating an image with imagefilledpoly gon(), 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
1807
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 nice, but I can build that outside. I can create a graph and set values, that works. the setColor method seems to do nothing, but then again, I have no idea what it's supposed to accept - many of the functions are expecting hard-coded values (e.g....
117
7273
by: Peter Olcott | last post by:
www.halting-problem.com
28
5224
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(); .... and then call the virtual method, why is it that the base class's method is called instead of the overridden method? How do I fix this if I don't know at runtime what the child class is? I'm using Activator.CreateInstance() to load the...
6
3815
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 is more that 1249 bytes, then the progress bar of the browser will move too slow and then displaying that the page not found!!!! If the message is less than or equal to 1249 then no problem.
0
1137
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 php script. I'm still a bit new to PHP, so I'm sure how to go about this, so I'm looking for a little guidance. The script I have runs queries and returns data. Some of the data is for a single plot on a graph and some data will represent...
2
2820
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 Googling the error, it seems that I was missing Freetype support. I've installed Freetype and rebuilt PHP with Freetype support, but I still get the same error. I look at the output from phpinfo() and I see that PHP was compiled with this switch:...
0
1184
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 looks like things are working, but I should be able to call the font by name instead of having to code its path. TIA
0
1350
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 calling a font. I can hard code the path to the font, so it looks like things are working, but I should be able to call the font by name instead of having to code its path. TIA
3
3071
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 1) I'm trying to bold the line. 2) I would also like to make the title bold... 3) I want to include a text inside the graph in the right corner
0
9670
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9518
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10430
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10159
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
6776
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5436
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5560
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4111
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2917
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.