Jump to content

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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.