mediacapture-image icon indicating copy to clipboard operation
mediacapture-image copied to clipboard

Optional MIME type as argument for takePhoto()

Open anonmos opened this issue 3 years ago • 0 comments

Problem

MIME types cannot be specified as part of the takePhoto() method. The Blob that is returned is the browser default MIME type.

Description

I'm currently using the imagecapture-polyfill library, but find myself having to fork it and use it as a separate library because the takePhoto() method doesn't allow for the specification of a MIME type in its blob creation.

It also appears that the takePhoto() w3c specification does take an argument for PhotoSettings, but that seems like it would be an inappropriate place to shoehorn the MIME type.

Proposal

Update the takePhoto() method within the Media Capture Image spec to include the following function signature:

takePhoto(optional PhotoSettings photoSettings = {}, optional String mimeType)

Pass this MIME type as part of the canvasElement.toBlob() call within the takePhoto() method so that the Blob can have the proper MIME type prepended.

Related Work

  • https://github.com/w3c/mediacapture-image/pull/185

anonmos avatar Apr 07 '21 23:04 anonmos