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
    Jan 2006
    Location
    Finland, Hollola
    Posts
    285
    Thanks
    8
    Thanked 0 Times in 0 Posts

    Transparent PNG 24bit How?

    Hi,

    I have tried PHP manual scripts without luck.

    My latest try:

    PHP Code:
    <?php

    $size 
    300;
    $image=imagecreatetruecolor($size$size);

    // something to get a white background with black border
    $back imagecolorallocatealpha($image200200200);
    $border imagecolorallocate($image000);
    imagefilledrectangle($image00$size 1$size 1$back);
    imagerectangle($image00$size 1$size 1$border);

    $yellow_x 100;
    $yellow_y 75;
    $red_x    120;
    $red_y    165;
    $blue_x   187;
    $blue_y   125;
    $radius   150;

    // allocate colors with alpha values
    $yellow imagecolorallocatealpha($image255255075);
    $red    imagecolorallocatealpha($image2550075);
    $blue   imagecolorallocatealpha($image0025575);

    // drawing 3 overlapped circle
    imagefilledellipse($image$yellow_x$yellow_y$radius$radius$yellow);
    imagefilledellipse($image$red_x$red_y$radius$radius$red);
    imagefilledellipse($image$blue_x$blue_y$radius$radius$blue);

    // don't forget to output a correct header!
    header('Content-type: image/png');

    // and finally, output the result
    imagepng($image);
    imagedestroy($image);
    ?>
    It says cannot output image or something. It's because the $back = imagecolorallocatealpha should not be alpha.

    How do I create a transparent PNG with alpha. I DO NOT want a background. I'd like to be able to mouse right click the image and save to my cpu and when I put it on any image, it will be transparent.
    PHP 5 & MySQL 5 (Y)

  • #2
    Senior Coder rafiki's Avatar
    Join Date
    Aug 2006
    Location
    Floating around somewhere...
    Posts
    2,042
    Thanks
    19
    Thanked 42 Times in 42 Posts
    why not create the image with GIMP/PS, then you could manipulate it with php

  • #3
    Regular Coder
    Join Date
    Jan 2006
    Location
    Finland, Hollola
    Posts
    285
    Thanks
    8
    Thanked 0 Times in 0 Posts
    This would be an alternative to ps. I'm creating simple graphs without my ps computer
    PHP 5 & MySQL 5 (Y)


  •  

    Posting Permissions

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