Jump to content


Photo

transparent background


  • Please log in to reply
5 replies to this topic

#1 neugi

neugi
  • Members
  • PipPipPip
  • Advanced Member
  • 63 posts

Posted 27 June 2006 - 12:06 PM

Hi,

i use the following 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);
?>

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

best

#2 DaveLinger

DaveLinger
  • Members
  • PipPipPip
  • Advanced Member
  • 268 posts
  • LocationWV, USA

Posted 27 June 2006 - 12:33 PM

Right click -> "Select All" -> Backspace.
http://www.DaveLinger.com
dave at linger dot com

#3 neugi

neugi
  • Members
  • PipPipPip
  • Advanced Member
  • 63 posts

Posted 27 June 2006 - 12:44 PM

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

i mean to remove the white background.

best

#4 DaveLinger

DaveLinger
  • Members
  • PipPipPip
  • Advanced Member
  • 268 posts
  • LocationWV, USA

Posted 27 June 2006 - 01:08 PM

what do you expect to get instead of the white background?

White IS the default, you know.
http://www.DaveLinger.com
dave at linger dot com

#5 maxim

maxim
  • Members
  • PipPipPip
  • Advanced Member
  • 48 posts

Posted 27 June 2006 - 01:44 PM

i know you can do this

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

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]

#6 neugi

neugi
  • Members
  • PipPipPip
  • Advanced Member
  • 63 posts

Posted 28 June 2006 - 06:41 AM

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




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users