Jump to content

GD problem with linux


Gruzin

Recommended Posts

Hi guys,

 

I'am haveing some trouble with GD images, the code (from phpfreaks) works just fine on windows, but it fails on Linux and I get something like this:

 

?PNG  IHDR2?PLTE 鲿`?L.IDAT?c`??a??|(?Ҍ?3Υ??yێC鿐??ގӬS? ^od,;IEND?B`?

 

here is the code:

 

 <?php 
        header ("Content-type: image/png"); 
        $img_handle = ImageCreate (230, 20) or die ("Cannot Create image"); 
        $back_color = ImageColorAllocate ($img_handle, 0, 10, 10); 
        $txt_color = ImageColorAllocate ($img_handle, 233, 114, 191); 
        ImageString ($img_handle, 31, 5, 5,  "My first Program with GD", $txt_color); 
        ImagePng ($img_handle); 
    ?> 

 

P.S I've checked phpinfo and GD Support is enabled.

 

You help is very appreciated,

George

Link to comment
https://forums.phpfreaks.com/topic/44893-gd-problem-with-linux/
Share on other sites

I know that linux is case sensitive...try it again where you have the functions written as:

 

ImageCreate -> imagecreate

ImagePng -> imagepng

 

Can't think of other problems...you sure you installed the right GD lib from the repostorys (or whatever you spell that :P)?

 

[depends on what distribution you use] apt-get install php5-gd

 

and:

 

[depends on what distribution you use] apt-get install php5-gd2

 

Full-Demon

Link to comment
https://forums.phpfreaks.com/topic/44893-gd-problem-with-linux/#findComment-218015
Share on other sites

Full-Demon,

 

Thanks a lot mate, but i've figured it out:

 

Check to be sure you don't print any code begore the header() function call. If you print anything else to the browser page, PHP will generate a default content-type of text/html for you. This would cause the image to not be processed correctly, giving you the behavior you describe.

If you want to display the graphic inline, you could save it as a file, then include it. Of course, you'd have to be creative if you're getting a lot of concurrent hits. (Maybe save image with a session ID then periodically destroy old images to save space)

Link to comment
https://forums.phpfreaks.com/topic/44893-gd-problem-with-linux/#findComment-218045
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.