Hey someone Help need GD for PHP that supports Jpeg GIF and PNG Images
Whenever i try to use GIF or JPG i get no output what do i do?
Help!!!!!!!!!!!!1
Hey someone Help need GD for PHP that supports Jpeg GIF and PNG Images
Whenever i try to use GIF or JPG i get no output what do i do?
Help!!!!!!!!!!!!1
Kirths,
First off, you won't get support for JPEG, GIF, and PNG at the same time. It's either JPEG/PNG or GIF, but not both. GIF support was removed from GD after version 1.6.2 as the compression used in producing GIF's is proprietary and closed-source. As zlib is used for JPEG, that's where the module is headed.
Now, solutions.....
Do you have some samples of the code producing no output that you can post? When you call phpinfo(), do you see a GD section in the output? Are you running on Win32 or Nix? If Win32, is the line "extension=php_gd.dll" uncommented in php.ini (or are you calling dl("php_gd.dll") from within your script)? If Nix, same question as Win32, just substitute .so for .dll. Also, if on *Nix did you compile PHP using the --with-gd[=dir], --with-jpeg[=dir], --with-png[=dir] make options?
Cheers,
Geoff A. Virgo
I am using win 2000
the php_gd.dll line is uncommented in the php.ini file in c:\winnt\
I cannot use ImageJpeg command as it give error..
what is the problem?
K
I am also having problems.
Im running windows and apache, the error is:
ImageGif: No GIF support in this PHP build
should i be using jpeg instead?
is there somewhere i can dowload a php build (win32 binary) with any graphic support compiled in it?
im not fussy which graphic type.
thanks.
Please ignore my previous message i managed to get it to create a JPEG. :-)
Thanks anyway
Kirths,
Does the php_gd.dll file exist in the path specified by the extension_dir directive in php.ini? If not you may have downloaded the "small" distribution form php.net. You need the grab the "big" one (about 4.5 M as the other doesn't have any extensions, like GD, compiled with it. Again, do you see a GD section in the output of phpinfo()? If not, the GD module isn't being loaded (even thought it's uncommented in php.ini) and that's way you're script is failing. If you do see a GD section in the output, post some sample code of how you're calling ImageJpeg()....... I can't try and figure out why it's failing if I don't know how it's being used.
Cheers,
Geoff A. Virgo
The phpinfo() command shows support fot GD.
As the imagejpeg command was not being taken i have instead downloaded the php_gif_gd.dll fine and renamed it to php_gd.dll
now the imagegif command is supported but i get junk characters..
Here is the code that i used:---<?php
//draw1.php
//Header("Content-type: image/gif");
$image=ImageCreate(200,150);
$gray=ImageColorAllocate($image,204,204,204);
$blue=ImageColorAllocate($image,0,0,255);
ImageLine($image,10,10,150,30,$blue);
ImageArc($image,150,65,70,70,0,360,$blue);
ImageRectangle($image,10,65,150,140,$blue);
Imagegif ($image);
ImageDestroy($image);
?>
Kirths
Dear sir,
We have installed PHP and found that the command imgaejpeg was not supported in the coading. So i downloaded php_gif_gd.dll and renamed it to php_gd.dll. I am running windows 2000 Advance server. The PHPINFO() command says that we have GD support. And the php_gd.dll command in php.ini is uncommented.
Whenever i run the following program with the following command imagegif (the command is now supported i get junk characters).
What do i do??
Here is a copy of the code i am using.
Your Immediate response and comments will be much appreciated.
P
<?php
//draw1.php
//Header("Content-type: image/gif");
$image=ImageCreate(200,150);
$gray=ImageColorAllocate($image,204,204,204);
$blue=ImageColorAllocate($image,0,0,255);
ImageLine($image,10,10,150,30,$blue);
ImageArc($image,150,65,70,70,0,360,$blue);
ImageRectangle($image,10,65,150,140,$blue);
Imagegif ($image);
ImageDestroy($image);
?>
Kirths,
I quickly hacked ran your code on my machine with an image as the result. The only changes I made was to uncomment the Header() funtion (and I used the JPEG functions since I don't have php_gif_gd.dll). You need to send the output in the correct mime-type for the browser to be able to decode it (hence the header()). Try uncommenting the line. If that still doesn't work, try re-naming the php_gif_gd.dll file back to it's original name and adding that to your php.ini. Don't know why it should make a difference, but GD on Win32 can be a pretty contrary beast. Regarding the server platform, you shouldn't have any troubles because you're running on Win2K (I'm assuming IIS). I've gotten the JPEG version up and working on a Win2K Server Pro box running whatever build of IIS 5 M$ had bundled on the disc. HTH, let me know if it works.
Cheers,
Geoff A. Virgo
HEllo All
Kirths,
I am having the same problem but after I read Geoff msg about gif not an open source I thought that I might not find a host that supports gif. Then I will be screwed and I will limit my chances to get a good host. I think I will switch to PNG.
Geoff,
What do you think? Is PNG widdly supported by browsers?
Well i uncommented the header line like you said and i get this:---
Warning: Cannot add header information - headers already sent by (output statred at d:\inetpub\wwwroot\kitths\image.php:2)in d:\intetpub\wwwroot\kirths\image.php on line 4
and then junk characters..
PS: can you also send me you e-mail address
Mine is : kirths@yahoo.com
And if you can sedn me your php_gd.dll file i would be much obliged.
K
Here is the copy of the code again:
<?php
//draw1.php
Header("Content-type: image/jpeg");
$image= ImageCreate(300,150);
$gray= ImageColorAllocate($image,204,204,204);
$blue= ImageColorAllocate($image,0,0,255);
ImageLine($image,10,10,150,30,$blue);
ImageArc($image,150,65,70,70,0,360,$blue);
ImageRectangle($image,10,65,150,140,$blue);
ImageJpeg ($image);
ImageDestroy($image);
?>
And when i remove the header the program runs but i still get junk characters -- a page full of them
K
The junk characters are the image itself. If you dont want them then you should save the image and then link to it. Thats is why you need the header declaration. When it says the header info is already sent then it means you have outputed something before it. Possibly some debug code, remove this and this error should go away also.
Dear Geoff,
I am very sorry. I deleted your e-mail from my account and now do not have it. If you re-email it i will be grateful.
By the way the only thing i did to sove the php image desplay problem was that i deleted all the empty lines before <?php in the php file and it desplayed the Image.. Strange but it worked.
I have come across another unexpected problem. Wonder if you could help here.
I have written the following code and it runs perfectly when i save the location of the image a.jpg in a FAT (non NTFS partition). else i get the
error
Warning: imagejpeg: unable to open 'd:\inetpub\wwwroot\kirths\temp\a.jpg' for writing in d:\inetpub\wwwroot\Kirths\RBarFile.php on line 52
I believe that i have to set NTFS permissons to the folder or for the software.
I am using windows 2000 Advance server and am running PHP4.05 and IIS ..
Please help me and advise on how to set the directory permissions.
Here is a sample of the code:--
<?php
//graph diagram:-
//Header("Content-type: image/jpeg");
// I have taken 'TWO' variables for better readability.
$row=300;
$col=2*$row;
$image = ImageCreate($col,$row);
//***Colours Used:-
$gray = ImageColorAllocate($image,220,220,220);
$red = ImageColorAllocate($image,255,0,0);
$blue = ImageColorAllocate($image,0,0,250);
$green = ImageColorAllocate($image,0,250,0);
$lightGreen = ImageColorAllocate($image,200,250,200);
$black = ImageColorAllocate($image,0,0,0);
//**Y Axis:-
ImageLine($image,(0.1$col),(0.9$row),(0.1$col),(0.1$row),$black);
//ImageLine($image,(0.08$col),(0.12$row),(0.1$col),(0.1$row),$black);
ImageLine($image,(0.09$col),(0.12$row),(0.1$col),(0.1$row),$black);
ImageLine($image,(0.1$col),(0.1$row),(0.11$col),(0.12*$row),$black);
//Opening Data File:-
$dfile = "D:\Inetpub\wwwroot\Kirths\Text Files\BarData.txt";
if(!($df = fopen($dfile,"r"))) die ("Cannot open data file.");
//**Bars on X Axis:-
$tcol = 0.2;
$bcol = 0.22;
While(!(feof($df)))
{
$data=(int)fgets($df,4);
$barLen=$row-($data/100$row)-(0.1$row);
ImageFilledRectangle($image,($tcol$col),($barLen),($bcol$col),(0.9$row),$red);
$tcol += 0.1;
$bcol += 0.1;
}
fclose($df);
// RK : commented out the following
//$string = "Rubix Infotech Inc.";
//ImageString($image,5,200,10,$string,$blue);
//**X Axis:-
ImageLine($image,(0.1$col),(0.9$row),(0.9$col),(0.9$row),$black);
ImageLine($image,(0.89$col),(0.88$row),(0.9$col),(0.9$row),$black);
ImageLine($image,(0.89$col),(0.92$row),(0.9$col),(0.9*$row),$black);
//***Display Image:-
ImageJPEG($image,"d:\inetpub\wwwroot\kirths\temp\a.jpg");
ImageDestroy($image);
?>
<H1><center>RUBIX Information Technologies, Inc</center></H1>
<H2><center>Data logging report</center></H2>
<center>
<image src="d:\inetpub\wwwroot\kirths\temp\a.jpg"></img>
</center>
<BR>
<image src="d:\inetpub\wwwroot\kirths\temp\a.jpg"></img>