Problem with png image

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • TheMadMidget
    New Member
    • Oct 2006
    • 98

    #1

    Problem with png image

    I had no problem with this code on my school's server, but when I moved it to mine it didn't work at all. Before it would make an image and display the text where I wanted it to, but now if Firefox all it does it display the full URL of the php file and IE displays a lil blank image box. I'm not sure what version the old server had, but mine has php 5.2.1. I copied over the whole folder, it's not like I'm missing a file there, but I'm wondering if it's just my PHP configuration, other PHP functions work fine.
    Code:
    <?php
    
    header("Content-type: image/png");
    $string = $_GET['text'];
    $im    = imagecreatefrompng("MouseOver.png");
    $black = imagecolorallocate($im, 0, 0, 0);
    $white = imagecolorallocate($im, 255, 255, 255);
    $px    = (imagesx($im) - 10 * strlen($string)) / 2;
    $font = imageloadfont("Occidental.gdf");
    imagestring($im, $font, $px+1, 1+1, $string, $white);
    imagestring($im, $font, $px, 1, $string, $black);
    imagepng($im);
    imagedestroy($im);
    
    ?>
  • quill
    New Member
    • Mar 2007
    • 12

    #2
    Does your php version have the gd library installed?

    Comment

    • TheMadMidget
      New Member
      • Oct 2006
      • 98

      #3
      Originally posted by quill
      Does your php version have the gd library installed?
      Not unless it's included in the standard full installation, how would I do that?

      Comment

      • Atli
        Recognized Expert Expert
        • Nov 2006
        • 5062

        #4
        Find this line in your php.ini
        Code:
        ;extension=php_gd2.dll
        and change it to
        Code:
        extension=php_gd2.dll
        If your using apache you will have to restart it.
        IIS isn't supposed to need a restart, but might.

        Comment

        • TheMadMidget
          New Member
          • Oct 2006
          • 98

          #5
          That line wasn't there, I tried just adding it, but that didn't work. I'm using apache only and did a restart. I have no idea what's wrong.

          Comment

          • Atli
            Recognized Expert Expert
            • Nov 2006
            • 5062

            #6
            What php version are you using?

            Are you using Windows? If so did you install php with the installer?


            If you did install php 5.x on windows using the installer, a .dll file will be missing from your installation.

            Try downloading the zip version of the install from www.php.net and unzip it.
            Find the ext folder in the unzipped folder and copy the php_gd2.dll to the ext folder in your current php directory. (C:/Program Files/PHP/ext/) by default

            Then you will need to change / add the line as I showed you before and restart apache.

            That should do it.

            Comment

            • TheMadMidget
              New Member
              • Oct 2006
              • 98

              #7
              I'm using Windows, I tried using the installer, but it didn't seem to work so I left the files it made and used the zip version to include everything else. I checked my ext directory and the php_gd2.dll file is there.
              Don't know if it help but you can check this out:
              PHP Info

              Comment

              • Atli
                Recognized Expert Expert
                • Nov 2006
                • 5062

                #8
                If the file is there and you have edited the php.ini it should show up.

                Your phpinfo() shows the extension_dir as "./". You might have to find that in you php.ini and point it to the ext dir of your php installation.
                Based on your phpinifo() file I'd guess (C:/Server/PHP/ext/)

                And just be sure that you'r acctually editing the php.ini file that your phpinfo() refers to (C:\Server\PHP\ php.ini). I've spent hours editing the wrong one, never understanding why it didn't work :P

                Comment

                • TheMadMidget
                  New Member
                  • Oct 2006
                  • 98

                  #9
                  extension_dir = "./ext"
                  That and uncommenting the
                  extension=php_g d2.dll

                  I figured it was "stock" going to work. Thank you Atli for your persistence, otherwise I probably would of tried reinstalling everything and came back to here.

                  Comment

                  Working...