纯 Javascript 图像处理库(以二进制形式,不通过 DOM) [英] Pure Javascript image handling library (in binary form, not through DOM)

查看:21
本文介绍了纯 Javascript 图像处理库(以二进制形式,不通过 DOM)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

因为 File API 将允许访问 content 本地文件现在可以在上传之前调整图像大小(一项相当常见的任务),无需任何额外的技术,如 Flash 或 Silverlight.除了我找不到任何能够以二进制形式处理图像的 Javascript 库.有没有?也许Flashe的ECMA脚本中有一些可以改编,但我根本找不到任何东西.

Since File API will enable access to the content of local files it is now possible to do image resize before upload (a fairly common task) without any additional technology like Flash or Silverlight. Except that I can't find any Javascript library that would be able to handle images in binary form. Is there any? Maybe there is some in Flashe's ECMA script that could be adapted, but I simply can't find anything.

推荐答案

虽然我还没有找到这样的库,但我已经找到了如何完成所描述任务的方法:

Although I haven't find such libs, I have found a way how to accomplish the described task:

  • Read image as Data URL
  • Load an image into a canvas tag and resize it
  • Encode canvas image data into some image format, for example JPG. Or use Canvas.toDataUrl() and then (optionaly) some base64 decoder.

客户端图像调整大小并使用纯 javascript 上传.这很酷,不是吗?

Client side image resizing and upload with pure javascript. That's cool, isn't it?

这篇关于纯 Javascript 图像处理库(以二进制形式,不通过 DOM)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆