From e850c886b2521016e1cba4f392247af1039dd4ec Mon Sep 17 00:00:00 2001 From: Michael Weibel <307427+mweibel@users.noreply.github.com> Date: Fri, 28 Aug 2020 10:49:11 +0200 Subject: [PATCH] fix: use image/jpeg as the target format when using the Chrome's native ImageCapture it outputs a JPEG. Default [`HTMLCanvasElement.toBlob()`](https://developer.mozilla.org/en-US/docs/Web/API/HTMLCanvasElement/toBlob) outputs a `png` unless otherwise specified. This change aligns those two implementations. --- src/imagecapture.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/imagecapture.js b/src/imagecapture.js index dcce0fc..1055851 100644 --- a/src/imagecapture.js +++ b/src/imagecapture.js @@ -123,7 +123,7 @@ if (typeof ImageCapture === 'undefined') { self.canvasElement.width = self.videoElement.videoWidth; self.canvasElement.height = self.videoElement.videoHeight; self.canvas2dContext.drawImage(self.videoElement, 0, 0); - self.canvasElement.toBlob(resolve); + self.canvasElement.toBlob(resolve, "image/jpeg"); } catch (error) { reject(new DOMException('UnknownError')); }