Jump to content

imagerotate


Craig Hopson
 Share

Recommended Posts

hi i have googled a bit for this but cant find a example off what im looking for 1..open image2..rotate image by 90deg3.. save image4..in a function that i can call using href if any one nows off such an example PLEASE post :good:

Link to comment
Share on other sites

ok i have the code (below) how do i change the output to save not display

<?php// File and rotation$filename = 'test.jpg';$degrees = 90;// Content typeheader('Content-type: image/jpeg');// Load$source = imagecreatefromjpeg($filename);// Rotate$rotate = imagerotate($source, $degrees, 0);// Outputimagejpeg($rotate);?>

Link to comment
Share on other sites

ok i have the code (below) how do i change the output to save not display
<?php// File and rotation$filename = 'test.jpg';$degrees = 90;// Content typeheader('Content-type: image/jpeg');// Load$source = imagecreatefromjpeg($filename);// Rotate$rotate = imagerotate($source, $degrees, 0);// Outputimagejpeg($rotate);?>

you have to supply imagejpeg a path to save the image to.http://php.net/manua...n.imagejpeg.php Edited by thescientist
Link to comment
Share on other sites

ok so i have this script

<?phpinclude("header.php");$img = $_GET['img'];   $imageinfo=getimagesize($img);  switch($imageinfo['mime'])  {   case "image/jpg":   case "image/jpeg":   case "image/pjpeg":	    $src_img=imagecreatefromjpeg("$img");			    break;    case "image/gif":	    $src_img = imagecreatefromgif("$img");			    break;    case "image/png":	    case "image/x-png":	    $src_img = imagecreatefrompng("$img");			    break;  }  $src_img = imagerotate($src_img, 90, 0);imagejpeg ($src_img,$img);echo '<meta http-equiv="refresh" content="0; URL=viewer.php">';?>

using like this

<a href="rotate.php?img=uploads/'.$id.'/'.$file.'">Rotate</a>

all works well but when it redirects back to viewer.php the image hasn't changed UNTILL you refresh the page any ideas here is viewer.php

echo '<div style="width:710px;">';$handle = opendir(dirname(realpath(__FILE__)).'/uploads/'.$id.'/');echo '<ul class="gallery">';  while($file = readdir($handle)){   if($file !== '.' && $file !== '..' && $file !== 'index.html'){    echo '    <li>    <div>    <a href="uploads/'.$id.'/'.$file.'">    <img src="uploads/'.$id.'/'.$file.'" border="0" style="padding:10px;" height="100px" width="100px" />    </a>    </div>    <div>    <a href="rotate.php?img=uploads/'.$id.'/'.$file.'">Rotate</a>    </div>    </li>    ';   }  } echo '</ul></div>';

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...