Jump to content

using functions


Craig Hopson
 Share

Recommended Posts

hi guys i have this function to rotate images

  function rotate($img,$rot){//get the detail of the image  $imageinfo=getimagesize($img);  switch($imageinfo['mime'])  {   //create the image according to the content type   case "image/jpg":   case "image/jpeg":   case "image/pjpeg": //for IE	    $src_img=imagecreatefromjpeg("$img");			    break;    case "image/gif":	    $src_img = imagecreatefromgif("$img");			    break;    case "image/png":	    case "image/x-png": //for IE	    $src_img = imagecreatefrompng("$img");			    break;  }  //rotate the image according to the spcified degree  $src_img = imagerotate($src_img, $rotation, 0);  //output the image to a file  imagejpeg ($src_img,$img);}

i know how to call it "rotate($img,$rotation)" but how do i USE it

<img src="uploads/'.$id.'/'.$file.'" style="border:5px groove lightblue;" height="100px" width="100px"/><a href="rotate(uploads/'.$id.'/'.$file.',90)" >Rotate 90</a>

I KNOW THE LAST CODE IS WRONG BECAUSE WE CANT USE SERVERSIDE FUNCTIONS BROWSER SIDEbut how is it done correctly Thanks

Link to comment
Share on other sites

you can point to a php file in the link which will execute that function. if you point to the php page where the function will execute, in src attribute, it will show up the image <img src='/yourdir/rotate.php'> in second case you have to output the result with appropiate header.

Edited by birbal
Link to comment
Share on other sites

Guest So Called

How about just using CSS? CSS: Rotate Text / Image Elements by 90, 180 or 270 Degrees

The CSS rules you need for a rotation of 90 degrees: /* for firefox, safari, chrome, etc. */-webkit-transform: rotate(-90deg);-moz-transform: rotate(-90deg);/* for ie */filter: progid:DXImageTransform.Microsoft.BasicImage(rotation=3);
Or otherwise you can write a PHP script that echoes the appropriately encoded image including headers, as suggested above. ETA: Read this article too:http://www.w3schools.com/cssref/css3_pr_transform.asp Edited by So Called
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...