Jump to content

transparent background


neugi

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
Link to comment
https://forums.phpfreaks.com/topic/13014-transparent-background/
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
Link to comment
https://forums.phpfreaks.com/topic/13014-transparent-background/#findComment-50061
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]
Link to comment
https://forums.phpfreaks.com/topic/13014-transparent-background/#findComment-50083
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.