imagecreatefrompng() screwing up transparency

Discussion in 'PHP' started by . Jordan ., Aug 1, 2010.

  1. #1
    So I'm making a random image script however when I output the image to the browser, it mucks up the transparent background by turning it black. Is there any way I can stop it from doing this and have it simply return the image properly? :p

    The code I'm using to output the image:

    header('Content-type: image/png');
    $srcImg = imagecreatefrompng($dir . '/' . $filename);
    imagepng($finalImg);
    PHP:
     
    . Jordan ., Aug 1, 2010 IP
  2. Tonic-_-

    Tonic-_- Peon

    Messages:
    2
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #2
    This try.
    header('Content-type: image/png');
    $srcImg = imagecreatefrompng($dir . '/' . $filename);
    imagesavealpha($finalImg, true);
    imagepng($finalImg);
    PHP:
     
    Tonic-_-, Aug 1, 2010 IP