Harley1979 Posted August 20, 2007 Share Posted August 20, 2007 I am using this code to rotate an image 90 degrees counterclockwise and clockwise. Each time the links are clicked, $i should increment/decrement, returning a result from the array which is used in the imagerotate line. <?php $getImage = "../directory/test.jpg"; $src = imagecreatefromjpeg($getImage); &angle[1] = 0.0; &angle[2] = 90.0; &angle[3] = 180.0; &angle[4] = 270.0; if (empty($i)){ $i = 1; } if ($i > 4){$i = 1} if ($i < 1){$i = 4} $rotate = imagerotate($src, $angle[$i], 0); imagejpeg($rotate, "../directory/test.jpg", 100) ?> <a href="?i=<?php $i + 1 ?>">Rotate clockwise</a> <a href="?i=<?php $i - 1 ?>">Rotate counter clockwise</a> I just can't seem to get this to work properly, any help would be really appreciated. Thanks Link to comment https://forums.phpfreaks.com/topic/65795-solved-image-rotate-problem/ Share on other sites More sharing options...
Harley1979 Posted August 20, 2007 Author Share Posted August 20, 2007 Sorry I should have made that more specific. The image rotates ok, but the value I am passing through the string to increment/decrement the $angle array doesn't work properly. Thanks Link to comment https://forums.phpfreaks.com/topic/65795-solved-image-rotate-problem/#findComment-328714 Share on other sites More sharing options...
itsmeArry Posted August 20, 2007 Share Posted August 20, 2007 try this out <?php $getImage = "../directory/test.jpg"; $src = imagecreatefromjpeg($getImage); $angle[1] = 0.0; $angle[2] = 90.0; $angle[3] = 180.0; $angle[4] = 270.0; if (empty($i)){ $i = 1; } if ($i > 4){$i = 1} if ($i < 1){$i = 4} $rotate = imagerotate($src, $angle[$i], 0); imagejpeg($rotate, "../directory/test.jpg", 100) ?> <a href="?i=<?php echo ($i + 1); ?>">Rotate clockwise</a> <a href="?i=<?php echo ($i - 1); ?>">Rotate counter clockwise</a> Link to comment https://forums.phpfreaks.com/topic/65795-solved-image-rotate-problem/#findComment-328717 Share on other sites More sharing options...
Harley1979 Posted August 20, 2007 Author Share Posted August 20, 2007 No joy, it's a wierd thing, even though I have that if statement that catches the $i at 4 and sends it back to 1, I seem to be getting 0 and 5 which is completely throwing things. Link to comment https://forums.phpfreaks.com/topic/65795-solved-image-rotate-problem/#findComment-328731 Share on other sites More sharing options...
itsmeArry Posted August 20, 2007 Share Posted August 20, 2007 sorry missed one line try this <?php $getImage = "../directory/test.jpg"; $src = imagecreatefromjpeg($getImage); $angle[1] = 0.0; $angle[2] = 90.0; $angle[3] = 180.0; $angle[4] = 270.0; $i = $_GET['i']; if (!isset($i) || $i == ''){ $i = 1; } if ($i > 4){$i = 1} if ($i < 1){$i = 4} $rotate = imagerotate($src, $angle[$i], 0); imagejpeg($rotate, "../directory/test.jpg", 100) ?> <a href="?i=<?php echo ($i + 1); ?>">Rotate clockwise</a> <a href="?i=<?php echo ($i - 1); ?>">Rotate counter clockwise</a> Link to comment https://forums.phpfreaks.com/topic/65795-solved-image-rotate-problem/#findComment-328737 Share on other sites More sharing options...
Harley1979 Posted August 20, 2007 Author Share Posted August 20, 2007 Thanks, works like a charm now! Link to comment https://forums.phpfreaks.com/topic/65795-solved-image-rotate-problem/#findComment-328741 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.