【发布时间】:2018-05-15 18:32:32
【问题描述】:
我正在尝试添加功能以在单击按钮时旋转图像,然后当单击提交按钮时,图像将被旋转保存。所以它不能只是使用CSS在视觉上旋转,而是图像文件本身旋转然后保存在原始图像文件的顶部。
我正在考虑使用imagerotate 使用 PHP 执行此操作,但仍然不能 100% 确定单击按钮时旋转图像的正确方法。然后在提交时保存该旋转按钮。
<?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);
// Free the memory
imagedestroy($source);
imagedestroy($rotate);
?>
只是不确定如何获取上述代码并在单击按钮时使其工作。然后在单击提交按钮时保存。如果有使用 javascript/jquery 的更简单的解决方案,如果它是一个更简单/更好的实现,我也可以使用它。
【问题讨论】:
标签: javascript php jquery image image-manipulation