W3C home > Mailing lists > Public > public-media-capture@w3.org > March 2012

RE: PROPOSAL: Simple image capture API

From: Travis Leithead <travis.leithead@microsoft.com>
Date: Tue, 13 Mar 2012 19:28:38 +0000
To: Anant Narayanan <anant@mozilla.com>, "public-media-capture@w3.org" <public-media-capture@w3.org>
Message-ID: <9768D477C67135458BF978A45BCF9B383827A270@TK5EX14MBXW604.wingroup.windeploy.ntdev.microsoft.com>
>-----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

This archive was generated by hypermail 2.4.0 : Friday, 17 January 2020 16:26:09 UTC