我希望用户能够顺时针或逆时针永久旋转图像文件。我试过 imagejpeg($rotate) 但似乎无法使其正常工作。
<form method="GET" action="rotate.php">
Rotate:<input type="radio" name="rotate" value="clockwise">Clockwise
<input type="radio" name="rotate" value="counterclockwise">Counter clockwise
<input type="Submit" name="Submit1"/>
</form>
我试图让用户能够选择单选按钮方向并单击“提交”。然后显示的图像将更新旋转到他们选择的任何方向,并在再次使用时永久保持这种状态。有什么帮助或指导吗?
<img src=\"uploads/$user/$folder/$image\"/></a>";
最佳答案
使用 imagerotate()
这将永久旋转图像。
<?php
// File and rotation
$filename = 'test.jpg';
$degrees = 180;
// Content type
header('Content-type: image/jpeg');
// Load
$source = imagecreatefromjpeg($filename);
// Rotate
$rotate = imagerotate($source, $degrees, 0);
// Output
imagejpeg($rotate);
?>
http://php.net/manual/en/function.imagerotate.php
或者你可以使用 jquery 来使用它
关于PHP永久旋转图像文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12541290/