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.
views:
363answers:
3
A:
Even if you do find something that understands images in pure javascript, you would still need the DOM to render it, making it incredibly slow.
Luca Matteis
2010-03-03 08:55:30
I don't want to render it, just upload it via AJAX PUT or POST requests. I'm sure that uploading works since I'm already doing it in my app, I just want to spare my bandwidth by moving the resize computation from server to client.
calavera.info
2010-03-03 10:42:19
+1
A:
Don't know if this is what you want, but there are some scripts on Userscripts.org that handle images: http://userscripts.org/scripts/show/38736
jerone
2010-03-03 10:22:17
+2
A:
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.
Client side image resizing and upload with pure javascript. That's cool, isn't it?
calavera.info
2010-03-03 11:53:34