Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    Regular Coder
    Join Date
    Jun 2007
    Posts
    805
    Thanks
    123
    Thanked 23 Times in 23 Posts

    PHP generate image - problems with background transparency

    Hi,

    I've got this code generating an image with some specified text on top of a specified background. The background is a .png image whith a transparent background. However, the php-generated image does not have the transparent background as the original image had - it's filled with black instead.

    The second picture is the original while the first is a screenshot of the php result:

    PHP Code:
    <?php 
    header
    ("Content-type: image/png"); 

    $image imagecreatefrompng("seddel.png");

    //imagecolorallocate($image, R, G, B) in HEX values
    $font_black imagecolorallocate($image218);

    $string "your text 1";


    //($image, fontsize, rightindent, downindent, data, txtcolour)
    imagestring($image3730$string$font_black);  


    imagepng($image); 
    imagedestroy($image); 

    ?>
    Does anybody know why this is caused and how to fix it?
    Attached Thumbnails Attached Thumbnails PHP generate image - problems with background transparency-untitled-2.png  
    Attached Images Attached Images  
    Last edited by CaptainB; 03-28-2009 at 08:18 AM.

  • #2
    Regular Coder sea4me's Avatar
    Join Date
    Jan 2009
    Location
    Damn, I don't know...
    Posts
    390
    Thanks
    11
    Thanked 28 Times in 27 Posts
    PHP can't retain transparent backgrounds....

    so you'll just have to edit it to white or something because currently PHP just makes they black

  • Users who have thanked sea4me for this post:

    CaptainB (03-28-2009)

  • #3
    Regular Coder
    Join Date
    Jun 2007
    Posts
    805
    Thanks
    123
    Thanked 23 Times in 23 Posts
    Damn, that sucks But thanks, it makes scense now.

    EDIT: There is not any other way to preserve transparency in PNG images while doing what I want?
    Also, if the answear is no, how would I then go around having only the text and NO background-color or image?
    Last edited by CaptainB; 03-28-2009 at 08:19 AM.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •