Wednesday, June 9, 2010

Image Rotate In PHP

Image Rotate In PHP

Here I am showing the code that will contentiously rotating  and Image.


The first file is:

 showImageRotate.php
< html >
< head >
< SCRIPT >
function init()  {
    setInterval("show();", 2000)
}
var dd = 1;
var cc=1;
var iii;
function show()  {
    if(dd>360) {
        dd=1;
    }
    iii=document.getElementById("div1");
    iii. innerHTML = " < img src= "imageRotate.php?degree=%22+dd+%22" / >";
    dd+=10;
}
< / SCRIPT >
< /head >
< body onLoad="init(); ">
< table width="200" border="0" >
  < tr >
    < td >            < /td >
    < td >             < /td >
    < td >< div id="div1" style="height:300px; width:500px">< /div >< /td >
  < /tr >
< /table >
< / body >
< / html >


And here is the second file:
 imageRotate.php

< ? php
// ImageRotate.php
$filename = 'a1.jpg';
$degrees =$_GET['degree'];
header('Content-type: image/jpeg');
$source = imagecreatefromjpeg($filename);
$white=imagecolorexact($source,255,255,255);
imagecolortransparent($source,$white);
$rotate = imagerotate($source, $degrees,$white);
imagejpeg($rotate);
? >

No comments:

Post a Comment