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
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
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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.