Is it possible to make transparent background image after rotating an image using php function image_rotate()? Thanks Samir
$transparent = imagecolorallocatealpha($destination_handle, 255, 255, 255, 0); imagealphablending($destination_handle, false); imagesavealpha($destination_handle,true); PHP: Saw this on another forum.. should help you. Just provide the RGB values in the first line for the color you want to make transparent. Oh and replace $destination_handle with the variable that is holding your image handle. ($var = imagecreate() or whatever)
Hi, Thanks for your reply. I am not how to use this code. TO rotate a image, i have used following code. Could you please tell me how can use your code there
I notice that code is the example on php.net's page Anyways, I just realized what I posted won't help you... I don't think. I think what I posted is only used when creating a new image with ImageCreate() or ImageCreateTrueColor(). It's a bit late so I'm not thinking straight and don't have the energy to go and search about this myself right now. Maybe someone else knows more about this than me and can help.
Hi Thanks for the reply. Actually I have tried to do after enough googling but not help found. Anyway, thanks again
Having the same problem with imagerotate on GD and the transparency problem... For me... the solution seemed to be making sure you knew the colour that was specified as transparent and then using this to pass into imagerotate(); Here's my example of creating a new transparent image and putting some text on it. Copying and pasting this might not work (ive not got time to test it, I've just taken the snippets out of my script that's far more complex) Hopefully though, the order of things done should give you an idea of what to try with your situation. $im = Imagecreatetruecolor(320,240); // New image $bg = ImageColorAllocateAlpha($im, 255,255,255, 127); // Transparent Background $fg = ImageColorAllocate($im, 0,0,0); // Font colour ImageFill($im, 0, 0 , $bg); // Fill with transparent background imagefttext($im, 12, 0, 0, 0, $fg, $fontName, "This is a test"); // Write some text to it $im = imagerotate($im,45,$bg); // Rotate 45 degrees and allocated the transparent colour as the one to make transparent (obviously) ImageSaveAlpha($im,true); // Finally, make sure image is produced with alpha transparency header('Content-type: image/png'); // Prepare header imagepng($im); // output imagedestroy($im); // clear memory PHP: