如何旋转图像并保存图像 [英] How to rotate image and save the image
问题描述
在我的应用程序有一个形象的一个div,一个按钮。
我要旋转显示的图像并保存旋转后的图像时,我按了一下按钮,使用jQuery。
我已经使用了code:
HTTP://$c$c.google.com/p/jquery-rotate/ 一>
和jQuery的code:
$(函数(){//文档就绪
变种旋转= 0; //变量做旋转与
$(#IMG)。点击(函数(){
旋转=(旋转+ 45)%360; //mod360可能是不需要的
$(#裁剪框),旋转(旋转);
});
});
HTML code:
< IMG SRC =demo_files / pool.jpgID =裁剪框/>
<输入类型=按钮ID =IMGNAME =IMG值=点击/>
在使用上述code I,有两个图像一个是旧形象,另一个是旋转的图像。
在这里,我要旋转相同的图像,并只显示旋转的图像。而且保存旋转后的图像伊娜目录。
我怎样才能做到这一点使用jQuery? 如果它是不可能与jQuery的话,我怎么能做到这一点可以用PHP / AJAX?
//定义图像路径
$文件名=image.jpg的;
//加载图像
$源= imagecreatefromjpeg($文件名);
//旋转
$旋转= imagerotate($源,$度,0);
//并将其保存在服务器上...
file_put_contents(myNEWimage.jpg,$旋转);
看看:
和
In my application i have an image in a div,a button.
I want to rotate the image displayed and save the rotated image when i clicked on the button using jquery.
I already used the code:
http://code.google.com/p/jquery-rotate/
and jquery code:
$(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 code:
<img src="demo_files/pool.jpg" id="cropbox" />
<input type="button" id="img" name="img" value="click" />
When i using above code ,There have two images one is the old image and another is the rotated image.
Here i want to rotate the same image and displaying only the rotated image .And save the rotated image ina directory.
How can i do this using jquery? If it is not possible with jquery then how can i do it possible with 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...
file_put_contents("myNEWimage.jpg",$rotate);
Take a look at:
And:
这篇关于如何旋转图像并保存图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!