Jump to content

[SOLVED] GD Library Question


phpQuestioner

Recommended Posts

I'm trying to start using PHP GD Library and I have checked php_info() on my server and GD Library is enable. I tried using a script from this site (http://www.phpfreaks.com/tutorials/105/0.php) to test if my GD Library worked and I kept getting the error "Image Not Found". I am running PHP 4.3.11 and I cannot find my "php_gd.dll" file; so I can not uncomment the lines I need to. Also, I went to php.net too look for binaries for 4.3.11 and could not find them.

 

Anyone one got any suggestions on where I can go to from here to either activate or make sure my GD Library is ready to work?

 

Because, right now; it does not seem to........

Link to comment
https://forums.phpfreaks.com/topic/63383-solved-gd-library-question/
Share on other sites

No, let me correct the error message. It is actually this error message:

 

The image “http://mydomain.com/08-04-2007.php” cannot be displayed, because it contains errors.

 

Here was code I used:

 

    <?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);
    ?> 

  • 3 weeks later...

OK - So I kind of put a pin in the this topic; and moved on to something else, but now I am back to it. I am still getting the same error message, because I just re-tested this code. I have include my gd info from my php_info() below; based on it, could someone tell me why PHP GD Image Code is not displaying/working?

 

gd-info.jpg

ok - i commented out the header, but no error - just this stuff:

 

 

‰PNG IHDRæ£þÓêPLTE ér¿`ŽLÚIDATxœåбAàŸMhF®!ža’+(„WÙË&ª;‘xë”Z…‡Ði'J­D£RÑ+®0wÁ¯`«ÙýòÏfø³Sc CYeŸGEý˜õà«*T,(´ªšðñ£Peí|&H»;?&¦±éÖ³½54IÇ%¥öÉé¿×‘[¢•!‘i¡)1kg$;ÇP E‚˜o™¶²,{»—z÷·†…Âå:`޾´¹Ì”¨Ž,³fSñƒ8Ÿ¨Æ7ȽíEµ¯E´ª,ÒNçÛ@µ4&‚øg••Gé2ü¶'€£D?ijžIEND®B`‚

Try:

 

<?php
        $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);
        header("Content-type: image/png");
        imagepng($img_handle);
?>

I found this script in the manual and it works, but now how do I scale it to be 100px X 100px ?

 

<?php
function LoadJpeg($imgname)
{
    $im = @imagecreatefromjpeg($imgname); /* Attempt to open */
    if (!$im) { /* See if it failed */
        $im  = imagecreatetruecolor(150, 30); /* Create a black image */
        $bgc = imagecolorallocate($im, 255, 255, 255);
        $tc  = imagecolorallocate($im, 0, 0, 0);
        imagefilledrectangle($im, 0, 0, 150, 30, $bgc);
        /* Output an errmsg */
        imagestring($im, 1, 5, 5, "Error loading $imgname", $tc);
    }
    return $im;
}
header("Content-Type: image/jpeg");
$img = LoadJpeg("2001-Dodge-Dakota.jpg");
imagejpeg($img);
?> 

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.