Hi all,

I need to rotate image with transparent background. I am using PHP5.1 and GD2.1.

I am creating a gif after rotation. Also tried to create png. but not getting transparent background. Also sometimes getting black background.

can any one help on this.

Thanks in advance

Fist off a few questions before I start helping you with you code:

  1. Do you have any code yet? If so may we see it?
  2. What file type do you want to save as? (You mention both PNG and GIF in your post)
  3. Do you want to rotate the image or do you want an animation of the image rotating? (GIF's can contain short animation and you mentioned them)
  4. And finally, if you only want a rotation...do you know how many degress? (It's alright to if that will be determined by user input.

If you could answer these, I will have a better understanding of what you are doing and be able to help you with your problems.

Rotate Image - I assume you mean randomly display an image from a list of images as opposed to actually rotating the image 90 degrees or something, right? (If not we can help with that too).

In its simplest form, random image with php:

<?PHP
$ri = array();

$ri[] = '<img src="image1.gif" />';

$ri[] = '<img src="image2.gif" />';

$ri[] = '<img src="image3.gif" />';

$ri[] = '<img src="image4.gif" />';

$num = rand(0,(count($ri)-1));
echo $ri[$num];
?>

You can add or subtract as many images as you want to that code, you can add html markup such as alt text, title tag, hyperlink, ect. You can literally put any html in between the single quotes as you like.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.