Jump to content


Photo

php image rotation question


  • Please log in to reply
2 replies to this topic

#1 Canman2005

Canman2005
  • Members
  • PipPipPip
  • Advanced Member
  • 669 posts

Posted 13 June 2006 - 12:32 AM

Hi all

I have the following script which takes an image and rotates it,

$filename = 'images/help.jpg';
$degrees = 350;
$source = imagecreatefromjpeg($filename);
imagecolortransparent($source,imagecolorat($source,0,0));  
$rotate = imagerotate($source, $degrees, 0);
$quality=100;
$image = imagejpeg($rotate,"",$quality);

The problem is that im left with a black background and I cannot seem to turn the background transparent.

Can anyone help?

Thanks in advance

Ed

#2 poirot

poirot
  • Members
  • PipPipPip
  • Advanced Member
  • 646 posts
  • LocationAustin, TX

Posted 13 June 2006 - 12:34 AM

imagerotate()'s third parameter defines the background color:

[!--quoteo--][div class=\'quotetop\']QUOTE[/div][div class=\'quotemain\'][!--quotec--]resource imagerotate ( resource src_im, float angle, int bgd_color )[/quote]
[a href=\"http://www.php.net/imagerotate\" target=\"_blank\"]http://www.php.net/imagerotate[/a]
~ D Kuang

#3 Canman2005

Canman2005
  • Members
  • PipPipPip
  • Advanced Member
  • 669 posts

Posted 13 June 2006 - 12:47 AM

Hi

so what background value keeps it transparent?

Thanks




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users