在我的应用程序中,我的 div 中有一个图像,一个按钮。
当我使用 jquery 单击按钮时,我想旋转显示的图像并保存旋转的图像。
我已经使用了代码:
http://code.google.com/p/jquery-rotate/ http://code.google.com/p/jquery-rotate/
和 jquery 代码:
$(function() { // doc ready
var rotation = 0; // variable to do rotation with
$("#img").click(function() {
rotation = (rotation + 45) % 360; // the mod 360 probably isn't needed
$("#cropbox").rotate(rotation);
});
});
html代码:
<img src="demo_files/pool.jpg" id="cropbox" />
<input type="button" id="img" name="img" value="click" />
当我使用上面的代码时,有两个图像,一个是旧图像,另一个是旋转图像。
在这里,我想旋转相同的图像并仅显示旋转后的图像。并将旋转后的图像保存在目录中。
我怎样才能使用 jquery 做到这一点?
如果 jquery 不可能,那么我怎样才能用 php/ajax 做到这一点?
//define image path
$filename="image.jpg";
// Load the image
$source = imagecreatefromjpeg($filename);
// Rotate
$rotate = imagerotate($source, $degrees, 0);
//and save it on your server...
imagejpeg($rotate, "myNEWimage.jpg");
看一眼:
图像旋转() http://php.net/manual/en/function.imagerotate.php
And:
file_put_contents() http://php.net/manual/en/function.file-put-contents.php
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)