HTML5 Canvas 实现本地压缩图片
来源:互联网 发布:软件技术优势怎么写 编辑:程序博客网 时间:2024/05/01 09:11
<!DOCTYPE html>
<html>
<body>
<p>要使用的图片:</p>
<img src="/i/eg_tulip.jpg" alt="tulip" id="tulip" style="margin-left:0px;" />
<p>Canvas:</p>
<canvas id="myCanvas" style="border:1px solid #d3d3d3;">
Your browser does not support the HTML5 canvas tag.
</canvas>
<script>
document.getElementById("tulip").onload=function(){
var c=document.getElementById("myCanvas");
var ctx=c.getContext("2d");
var img=document.getElementById("tulip");
ctx.drawImage(img,0,0,img.width,img.height,0,0,300,150);<!-- 这里将原图等比例压缩为300*150-->
};
</script>
</body>
</html>
<html>
<body>
<p>要使用的图片:</p>
<img src="/i/eg_tulip.jpg" alt="tulip" id="tulip" style="margin-left:0px;" />
<p>Canvas:</p>
<canvas id="myCanvas" style="border:1px solid #d3d3d3;">
Your browser does not support the HTML5 canvas tag.
</canvas>
<script>
document.getElementById("tulip").onload=function(){
var c=document.getElementById("myCanvas");
var ctx=c.getContext("2d");
var img=document.getElementById("tulip");
ctx.drawImage(img,0,0,img.width,img.height,0,0,300,150);<!-- 这里将原图等比例压缩为300*150-->
};
</script>
</body>
</html>
0 0
- HTML5 Canvas 实现本地压缩图片
- HTML5 Canvas 实现本地压缩图片
- HTML5+Canvas实现本地压缩上传图片功能
- html5+canvas实现图片的压缩上传
- html5 canvas 图片压缩
- HTML5利用Canvas压缩图片
- HTML5 canvas实现图片拉伸、压缩与裁剪
- canvas实现图片压缩
- HTML5+Canvas手机拍摄,本地压缩上传图片,案例实测报告。
- HTML5+Canvas手机拍摄,本地压缩上传图片,案例实测报告。
- 使用canvas实现图片压缩
- 使用canvas实现图片压缩
- 【图片压缩】使用canvas,html5进行图片压缩
- jquery扩展html5+canvas实现多张图片 预览 压缩 上传
- 用html5 canvas js 实现图片大小的压缩显示,图片上传后可在线预览。
- HTML5 file API加canvas实现图片前端JS压缩并上传
- H5 canvas实现客户端压缩图片上传
- 使用canvas实现图片压缩上传
- JAVA加密技术-----MD5 与SHA 加密
- 2014----激情复燃的时光
- ORA-04042 procedure, function, package, or package body does not exist
- 代码跟踪--初学cocos2dx
- Ubuntu下使用Monaco字体
- HTML5 Canvas 实现本地压缩图片
- 设置VM虚拟机从U盘启动装系统
- 刷沐丝
- 黑马程序员 面向对象(2)
- UVALive - 4725 Airport
- QT 多线程信号与槽(二)
- Struts2结合Jfreechart实现数据报表统计
- Android之Activity标题栏和状态栏设置
- 装了win7和win8双系统之后,怎么删除win8系统