RE: PROPOSAL: Simple image capture API

>-----Original Message-----
>From: Anant Narayanan [mailto:anant@mozilla.com]
>Sent: Tuesday, March 13, 2012 11:30 AM
>
>On Mar 13, 2012, at 11:13 AM, Travis Leithead wrote:
>> This has been said already, but I'll say it again... If you want "dead
>simple", then you should use the declarative-based approach. You can take
>pictures and submit them to servers without any script at all. This task
>force isn't really looking at the declarative model, though DAP has the
>spec. I think your feedback is certainly relevant for that spec.
>
>The declarative approach is not an API. There are cases where it is useful
>to be able to do this from script (and input.click() is not the "correct"
>way to achieve this), for instance if the app wants make changes to image
>locally via <canvas> before sending it off to the server (we have a real
>use case for this: Instagram).

Note, there is no way to programmatically invoke the file picker API 
(<input type=file>) primarily due to security reasons; you don't want
an attacker to pop that UI up having pre-configured it. Also, such a 
programmatic method lacks context. Most browsers added "popup blockers" 
because this type of programming was really annoying users :-)

Note, browsers will allow "popups" when a user-action started the process 
under some circumstances (which assumes that there is context for the action).

Programmatically activating the browser's camera UI via an API seems 
like a bad idea for similar reasons. I can see that this could be useful
in a more trusted environment (like an app), but for an untrusted environment
in a browser, I wouldn't endorse this approach.

If you really need an API, input.click() is not what you want. What you _really_
want is:

input.onfilesavailable = function(e) { /* get the Files from e.target.files */ }

Then just direct the user (via UI) to click on the input element, take a picture, and your 
code swoops in to process the File objects if you wish.



>I think this task force is the right place to define that API, as a
>complement to the declarative approach.
>
>Regards,
>-Anant
>
>

Received on Tuesday, 13 March 2012 19:29:21 UTC