imagerotate 


gd apg

ROTATE an image with a given angle.





The rotation $angle is interpreted as the number of degrees to rotate the image anticlockwise.

The $background_color specifies the color of the uncovered zone after the rotation.

If $ignore_transparent = 0 transparent colors are ignored, otherwise kept.

This function is affected by the interpolation method set by imagesetinterpolation and will be seen on the next page.

This function returns FALSE on failure.



<?php

GdImage
|false imagerotate (  GdImage $image,
                                                     
float $angle,
                                                        
int $background_color,
                                                     
bool $ignore_transparent false )


where,

$image The image identifier

$angle 
The rotation angle in degrees 

$background_color 
The color of the uncovered zone 
                                                after the rotation 

$ignore_transparent 
To control the transparent colors
                                        This parameter is unused

?>
 

  $image   


The image identifier.



  $angle   


The rotation angle in degrees.



  $background_color   


The color of the uncovered zone after the rotation.



  $ignore_transparent   


To control the transparent colors.



  1 EXERCISE   

<?php

echo 'PHP VERSION: ' PHP_VERSION '<br><br>';

$tst_img "gif/GIF 020 01.gif"// 256 colors
$dst1_img "gif/GIF 020 01(90 degrees).gif";
$dst2_img "gif/GIF 020 01(10 degrees).gif";
$dst3_img "gif/GIF 020 01(-10 degrees).gif";

echo 
$tst_img?>
<br><br><img src="<?php echo  $tst_img?>
alt="<?php echo $tst_img?>"><br><br><br><br>

<?php
$id_org 
imagecreatefromgif$tst_img);
$ang_r1 90;
$ang_r2 10;
$ang_r3 = -10;
$bkg_2 0xeeeeee;
// background color
$bkg_3 0xeeeeee;
// background color
$trn 100;
// this parameter is unused

$id_dst1 imagerotate($id_org$ang_r1NULL$trn );
imagegif ($id_dst1,  $dst1_img);

$id_dst2 imagerotate($id_org$ang_r2$bkg_2$trn );
imagegif ($id_dst2,  $dst2_img);

$id_dst3 imagerotate($id_org$ang_r3$bkg_3$trn );
imagegif ($id_dst3,  $dst3_img);

echo 
$dst1_img?>
<br><br><img src="<?php echo  
$dst1_img?>" alt="<?php echo $dst1_img?>"><br><br>


<?php echo $dst2_img?>
<br><br><img src="<?php echo  
$dst2_img?>" alt="<?php echo $dst2_img?>"><br><br>

<?php echo $dst3_img?>
<br><br><img src="<?php echo  
$dst3_img?>" alt="<?php echo $dst3_img?>"><br>


 RESULT   

GIF 020 01.gif

Existing Image

GIF 020 01.gif apr



GIF 020 01(90 degrees).gif

( 90° )

GIF 020 01(90 degrees).gif apr

GIF 020 01(10 degrees).gif

( 10° )

GIF 020 01(10 degrees).gif apr

GIF 020 01(-10 degrees).gif

( -10° )

GIF 020 01(-10 degrees).gif apr

  2 EXERCISE   

<?php

echo 'PHP VERSION: ' PHP_VERSION '<br><br>';

$tst_img "jpeg/JPEG 025 01.jpg"// TRUECOLOR
$dst1_img "jpeg/JPEG 025 01(90 degrees).jpg";
$dst2_img "jpeg/JPEG 025 01(10 degrees).jpg";
$dst3_img "jpeg/JPEG 025 01(-10 degrees).jpg";

echo 
$tst_img?>
<br><br><img src="<?php echo  $tst_img?>
alt="<?php echo $tst_img?>" width="400"><br><br><br><br>

<?php
$id_org 
imagecreatefromjpeg$tst_img);
$ang_r1 90;
$ang_r2 10;
$ang_r3 = -10;
$bkg_2 0xeeeeee;    // background color
$bkg_3 0xeeeeee;   // background color
$trn 0;                // this parameter is unused

$id_dst1 imagerotate($id_org$ang_r1NULL$trn );
imagejpeg ($id_dst1,  $dst1_img);

$id_dst2 imagerotate($id_org$ang_r2$bkg_2$trn );
imagejpeg ($id_dst2,  $dst2_img);

$id_dst3 imagerotate($id_org$ang_r3$bkg_3$trn );
imagejpeg ($id_dst3,  $dst3_img);

echo 
$dst1_img?>
<br><br><img src="<?php echo  
$dst1_img?>" alt="<?php echo $dst1_img?>" width="400"><br><br>


<?php echo $dst2_img?>
<br><br><img src="<?php echo  
$dst2_img?>" alt="<?php echo $dst2_img?>" width="400"><br><br>

<?php echo $dst3_img?>
<br><br><img src="<?php echo  
$dst3_img?>" alt="<?php echo $dst3_img?>" width="400"><br>


 RESULT   

JPEG 025 01.jpg

Existing Image

JPEG 025 01.jpg apr



JPEG 025 01(90 degrees).jpg

( 90° )

JPEG 025 01(90 degrees).jpg apr

JPEG 025 01(10 degrees).jpg

( 10° )

JPEG 025 01(10 degrees).jpg apr

JPEG 025 01(-10 degrees).jpg

( -10° )

JPEG 025 01(-10 degrees).jpg apr