Jump to content

Archived

This topic is now archived and is closed to further replies.

neugi

transparent background

Recommended Posts

Hi,

i use the following code:

[code]<?
    header("Content-type: image/png");
    $img_foto = "foto.png";
    $img_bild = "projekte/testhaus.jpg";
    $winkel = 7;
    $font = '../font/rabiohead.ttf';
    $text1 = "Hi";
    $text2 = "Text2";
    $text3 = "Text3";

    $img = imagecreatefrompng($img_foto);
    $foto = imagecreatefromjpeg($img_bild);

    $trans = imagecolorallocate($foto, 255, 255, 255);
    $white = imagecolorallocate($img, 255, 255, 255);

    $foto = imagerotate($foto, $winkel, $trans);

    $bild_x = imagesx($foto);
    $bild_y = imagesy($foto);
    $img_x_y = getimagesize($img_foto);

    imagecolortransparent($foto, $trans);

    imagecopymerge($img, $foto, -3, 28, 0, 0, $bild_x, $bild_y, 100);
    imagettftext($img, 20, $winkel, 20, 330, $grey, $font, $text1);

    imagecolortransparent($img, $white);

    imagepng($img);
    imagedestroy($img);
    imagedestroy($foto);
?> [/code]

and the result ist das i got a whit background. how can i remove this?

best

Share this post


Link to post
Share on other sites
[!--quoteo(post=388474:date=Jun 27 2006, 07:33 AM:name=DaveLinger)--][div class=\'quotetop\']QUOTE(DaveLinger @ Jun 27 2006, 07:33 AM) [snapback]388474[/snapback][/div][div class=\'quotemain\'][!--quotec--]
Right click -> "Select All" -> Backspace.
[/quote]
realy funny *lol*

i mean to remove the white background.

best

Share this post


Link to post
Share on other sites
what do you expect to get instead of the white background?

White IS the default, you know.

Share this post


Link to post
Share on other sites
i know you can do this

[code]//enable the .png image to retain its transperant properties
imageAlphaBlending($image, false);
imageSaveAlpha($image, true);[/code]

basicly if you using existing image which already has transperancey by default it will look black. so by adding that code it makes it transparent.

if you use imagecolortransparent() it only makes that 1 color transparent and is only good for low res 'blocky' images, hope that helps.

heres a image i made with the code i posted. as you can see the shadow is semi transparent something that is not possible with imagecolortransparent()

[a href=\"http://maximhome.no-ip.org/blog/?p=5\" target=\"_blank\"]http://maximhome.no-ip.org/blog/?p=5[/a]

Share this post


Link to post
Share on other sites
Hi,

the new problem is that i want to change the stuff to gif format, because auf the display problems with png in IE.

i've changed imagepng to imagegif

but as there is still the whit background :(

best

Share this post


Link to post
Share on other sites

×

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.