Home >Backend Development >PHP Tutorial >javascript - 手机端头像上传怎么做啊?还要带裁剪

javascript - 手机端头像上传怎么做啊?还要带裁剪

WBOY
WBOYOriginal
2016-06-06 20:23:501251browse

做微信开发,在手机端页面需要做到选择图片,然后剪切作为头像,各路大神给点意见,怎么弄啊?有没有demo?

回复内容:

做微信开发,在手机端页面需要做到选择图片,然后剪切作为头像,各路大神给点意见,怎么弄啊?有没有demo?

https://github.com/baijunjie/jQuery-photoClip

加个canvas标签
把文件用webapi读出来,转成base编码
把图片画到canvas上
写个裁减框,比如说一个透明的绝对定位的透明可拉伸div,覆盖到canvas上
对canvas施行clip,然后保存canvas为图片

微信端开发,图片上传建议用微信提供的那套jsapi,拿到图片之后通过canvas来处理,网上有很多案例,搜搜看

百度有一个webuploader做的还不错

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn