Jump to content

Images


spamoom

Recommended Posts

Hey all, I finally managed to get the gd2 libary installed on my server and started to look @ the gd tutorial on phpfreaks :D

 

I copied and pasted the code to see what would happen.....

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

 

I get this when I try and view the image in firefox

The image “path/img.php” cannot be displayed, because it contains errors.

 

And in ie it tries to load the image via quicktime !? and gives me a big question mark =P

 

Any Ideas for the image creation noob?

Link to comment
https://forums.phpfreaks.com/topic/45054-images/
Share on other sites

Remove the white space before the header() function and try again.  This (below) works perfectly:

 

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

Link to comment
https://forums.phpfreaks.com/topic/45054-images/#findComment-218720
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.