Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support to get and set desired image format #185

Closed
wants to merge 1 commit into from

Conversation

alexshalamov
Copy link

@alexshalamov alexshalamov commented Jun 15, 2017

This PR adds possibility for the web developers to get formats supported by the UA and set desired format for the captured photo.

Fixes #162


Preview | Diff

@alexshalamov
Copy link
Author

@YellowDoge please take a look.

index.bs Outdated
@@ -192,6 +192,7 @@ interface ImageCapture {
readonly attribute MediaSettingsRange imageHeight;
readonly attribute MediaSettingsRange imageWidth;
readonly attribute FrozenArray<FillLightMode> fillLightMode;
readonly attribute FrozenArray<DOMString> supportedImageFormats;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@YellowDoge I noticed that impl status.md has 'flattened' features for PhotoSettings and PhotoCapabilities, because attributes have same names. Should I rename 'image format' related attributes as well?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm don't fully grasp the question, could you please rewrite it or provide an example...?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

At the moment, PhotoCapabilities and PhotoSettings have same attribute names, even for arrays. For example PhotoCapabilities.fillLightMode represents supported fill light modes (supportedFillLightModes).

Question is that, what naming style should be used? If I follow current naming style, then PhotoCapabilities should have FrozenArray<DOMString> imageFormat attribute and PhotoSettings should have DOMString imageFormat attribute.

As the attribute names for PhotoCapabilities and PhotoSettings are the same (currently), implementation-status.md has just one column (Photo{Capabilities/Settings}).
If PhotoCapabilities and PhotoSettings would have different attribute names, it could be confusing and look like both have imageFormat and supportedImageFormats attributes.

Do you think implementation-status.md looks fine with my modifications?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see what you mean, sorry I was so thick, thanks for the explanation. The other cases in the current Spec that follow this pattern of FrozenArray<DOMString> as capabilities and DOMString for setting/constraining have the same name in both cases, e.g. exposureMode and exposureMode, so I'd say that for the purpose of this PR is better to follow that idea, and just use the name imageFormats leaving to the dictionary to resolve the semantics.

If this still looks confusing we could consider changing all of them at the same time, but take into account that Cr already shipped those.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@YellowDoge thanks for comments, I renamed attribute to Photo{Capabilities/Settings}.imageFormats

index.bs Outdated
@@ -691,6 +699,9 @@ When the {{getSettings()}} method is invoked on a video stream track, the user a
<li><dfn>Zoom</dfn> is a numeric camera setting that controls the focal length of the lens. The setting usually represents a ratio, e.g. 4 is a zoom ratio of 4:1. The minimum value is usually 1, to represent a 1:1 ratio (i.e. no zoom).</li>

<li><dfn>Fill light mode</dfn> describes the flash setting of the capture device (e.g. |auto|, |off|, |on|). <dfn>Torch</dfn> describes the setting of the source's fill light as continuously connected, staying on as long as {{track}} is active.</li>

<li><dfn>Image format</dfn> is the ASCII-encoded string in lower case describing the format of an image. The <a>image format</a> string MUST be a [=valid mime type=], whose [=type=] MUST be an [=image media type=] and [=subtype=] MAY be one of the [=IANA registered image subtypes=].
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think here we should specify that the UA should be able to display the format, similar to what we specify in e.g. MediaRecorder .

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added line similar to MediaRecorder

index.bs Outdated
@@ -240,6 +245,9 @@ interface ImageCapture {

<dt><dfn dict-member for="PhotoSettings"><code>fillLightMode</code></dfn></dt>
<dd>This reflects the desired <a>fill light mode</a> (flash) setting.</dd>

<dt><dfn dict-member for="PhotoSettings"><code>imageFormats</code></dfn></dt>
<dd>This reflects the desired <a>image format</a> for the captured photo. If the UA supports desired <a>image format</a>, the {{Blob/type!!attribute}} of the {{Blob}} produced by <a>takePhoto()</a> MUST be of the {{imageFormats!!dict-member}} [=image format|type=].</dd>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

s/MUST be of/MUST be one of/

s/{{imageFormats!!dict-member}}/{{PhotoCapabilities/imageFormats}}/ ?

Also, despite [= =] syntax being valid, this document uses mostly the likes of <a>image format</a>.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

s/MUST be of/MUST be one of/
s/{{imageFormats!!dict-member}}/{{PhotoCapabilities/imageFormats}}/ ?

Fixed, however, I would prefer original version. If web developer explicitly requests e.g., "image/tiff", proper type should be returned, or takePhoto() should fail if unsupported type was requested. Now, UA is allowed to return whatever it supports, regardless of provided PhotoSettings.

Also, despite [= =] syntax being valid, this document uses mostly the likes of image format.

Fixed. Is there a way to override display text for anchors? I use [==] in other specs that use bikeshed, as it is easier to make plurals or tailor text within different contexts.

Copy link
Member

@yell0wd0g yell0wd0g Jun 22, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would prefer original version. If web developer explicitly requests e.g., "image/tiff", proper type should be returned, or takePhoto() should fail if unsupported type was requested.

PhotoSettings is used for both setting a configuration and readback of the current one, so the text has to be valid for both, leaving the actions to the methods using the dictionary, so that e.g. takePhoto({imageFormat: "image/invalid"}); should reject indeed, but when we read it back, then we should explicit that the image format should be one of the supported ones (and not, e.g. blank).

index.bs Outdated
@@ -209,6 +210,9 @@ interface ImageCapture {

<dt><dfn attribute for="PhotoCapabilities"><code>fillLightMode</code></dfn></dt>
<dd>This reflects the supported <a>fill light mode</a> (flash) settings, if any.</dd>

<dt><dfn attribute for="PhotoCapabilities"><code>imageFormats</code></dfn></dt>
<dd>This reflects [=image format|image formats=] supported by the UA.</dd>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

s/reflects/reflects the/

index.bs Outdated
@@ -192,6 +192,7 @@ interface ImageCapture {
readonly attribute MediaSettingsRange imageHeight;
readonly attribute MediaSettingsRange imageWidth;
readonly attribute FrozenArray&lt;FillLightMode> fillLightMode;
readonly attribute FrozenArray&lt;DOMString> imageFormats;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

s/imageFormats/imageFormat/ to follow the fillLightMode convention.

index.bs Outdated
@@ -223,6 +227,7 @@ interface ImageCapture {
double imageHeight;
double imageWidth;
boolean redEyeReduction;
DOMString imageFormats;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here: s/imageFormats/imageFormat/ to follow the fillLightMode convention (and exposureMode etc).

index.bs Outdated
@@ -691,6 +699,9 @@ When the {{getSettings()}} method is invoked on a video stream track, the user a
<li><dfn>Zoom</dfn> is a numeric camera setting that controls the focal length of the lens. The setting usually represents a ratio, e.g. 4 is a zoom ratio of 4:1. The minimum value is usually 1, to represent a 1:1 ratio (i.e. no zoom).</li>

<li><dfn>Fill light mode</dfn> describes the flash setting of the capture device (e.g. |auto|, |off|, |on|). <dfn>Torch</dfn> describes the setting of the source's fill light as continuously connected, staying on as long as {{track}} is active.</li>

<li><dfn>Image format</dfn> is the ASCII-encoded string in lower case describing the format of an image. The <a>image format</a> string MUST be a [=valid MIME type=], whose [=type=] MUST be an [=image media type=] and [=subtype=] MAY be one of the [=IANA registered image subtypes=]. The UA should be able to display any of the supported [=image format| image formats=].
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

s/[=valid MIME type=]/{{valid MIME type}}/ ? Throughout.

@alexshalamov alexshalamov force-pushed the add_image_format branch 2 times, most recently from 594c54e to 563e6c7 Compare June 22, 2017 07:54
Copy link
Member

@yell0wd0g yell0wd0g left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm but let's see what @jan-ivar says.

index.bs Outdated
@@ -260,6 +265,9 @@ interface ImageCapture {

<dt><dfn dict-member for="PhotoSettings"><code>fillLightMode</code></dfn></dt>
<dd>This reflects the desired <a>fill light mode</a> (flash) setting.</dd>

<dt><dfn dict-member for="PhotoSettings"><code>imageFormat</code></dfn></dt>
<dd>This reflects the desired <a>image format</a> for the captured image. If the UA supports desired <a>image format</a>, the {{Blob/type!!attribute}} of the {{Blob}} produced by <a>takePhoto()</a> MUST be one of the {{PhotoCapabilities/imageFormat}} types.</dd>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd phrase the second sentence something like: When the UA returns a {{Blob}} from {{takePhoto()}}, the format and {{Blob/type}} MUST be one of the supported <a>image formats</a> enumerated in {{PhotoCapabilities/imageFormat}}, if any.

@alexshalamov
Copy link
Author

@jan-ivar could you please check this PR when you have a time?

Copy link
Member

@jan-ivar jan-ivar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi, back from a week off. Sorry for the delay!

index.bs Outdated
@@ -229,6 +230,9 @@ interface ImageCapture {

<dt><dfn attribute for="PhotoCapabilities"><code>fillLightMode</code></dfn></dt>
<dd>This reflects the supported <a>fill light mode</a> (flash) settings, if any.</dd>

<dt><dfn attribute for="PhotoCapabilities"><code>imageFormat</code></dfn></dt>
<dd>This reflects the <a>image format</a> supported by the UA.</dd>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe "This reflects the available <a>image format</a>s supported by the UA." - to capture that this is a list?

Do we want to add something like "The UA MUST support at least one image format"?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, will fix it as you proposed.

index.bs Outdated
@@ -260,6 +265,9 @@ interface ImageCapture {

<dt><dfn dict-member for="PhotoSettings"><code>fillLightMode</code></dfn></dt>
<dd>This reflects the desired <a>fill light mode</a> (flash) setting.</dd>

<dt><dfn dict-member for="PhotoSettings"><code>imageFormat</code></dfn></dt>
<dd>When the UA returns a {{Blob}} from {{takePhoto()}}, the format and {{Blob/type}} MUST be one of the supported <a>image formats</a> enumerated in {{PhotoCapabilities/imageFormat}}, if any.</dd>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These look like normative steps for the takePhoto algorithm, and should probably move there.

As currently written it doesn't actually say the UA should look at the imageFormat setting at all. @YellowDoge said that "takePhoto() should fail if unsupported type was requested" - That would be one way to go. But which error? We'd need to specify that.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, was OOO.
@jan-ivar I think proper error handling is missing from takePhoto algorithm. IMO, takePhoto should reject promise with NotSupportedError if PhotoSettings with unsupported value is provided.

For this PR, I can align this text with other dictionary members like:
"This reflects the desired <a>image format</a> setting."

If you and @YellowDoge think that takePhoto should reject promise, maybe it would be better to do it in separate PR. What do you think?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wfm. We should probably wait for #194 to merge before doing that anyway.

This PR adds possibility for the web developers to get formats supported by the UA and set desired format for the captured photo.

Fixes w3c#162
@alexshalamov
Copy link
Author

@jan-ivar #194 is merged, I've rebased this PR, could you please take a look?

Copy link
Member

@jan-ivar jan-ivar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm.

@alexshalamov
Copy link
Author

@YellowDoge Could you please merge the PR if you are fine with the changes.

@beaufortfrancois
Copy link
Contributor

@YellowDoge @riju What is the current status of this PR?

@riju
Copy link
Collaborator

riju commented Aug 20, 2020

I am missing some historical context and if there were specific customer asks @alexshalamov (no longer working at Intel) was privy to. IMO it looks like a good feature to have, but I think we should proceed with this only if there is proof of substantial customer interest, else we can keep this PR in this suspended state.

Base automatically changed from master to main February 15, 2021 07:19
@alvestrand
Copy link
Contributor

Closing due to lack of interest. We can always reopen if interest recovers.

@alvestrand alvestrand closed this Jan 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Provide way to get / set captured image format
6 participants