@@ -1320,6 +1320,7 @@ class Canvas {
13201320 }
13211321
13221322 /**
1323+ * <warn>This is for Node.js usage only, HTMLCanvasElement does not support this</warn>
13231324 * Render the canvas into a buffer.
13241325 * @param {any[] } args The render's options.
13251326 * @returns {Buffer }
@@ -1329,6 +1330,7 @@ class Canvas {
13291330 }
13301331
13311332 /**
1333+ * <warn>This is for Node.js usage only, HTMLCanvasElement does not support this</warn>
13321334 * Render the canvas into a buffer using a Promise.
13331335 * @returns {Promise<Buffer> }
13341336 */
@@ -1362,6 +1364,30 @@ class Canvas {
13621364 } ) ) ;
13631365 }
13641366
1367+ /**
1368+ * <warn>This is for web usage only, node-canvas does not support this</warn>
1369+ * Render the canvas into a Blob object representing the image contained in the canvas
1370+ * @param {Function } callback A callback function with the resulting `Blob` object as a single argument.
1371+ * @param {string } [mimeType] A string indicating the image format. The default type is `image/png`.
1372+ * @param {number } [qualityArgument] A number between 0 and 1 indicating image quality if the requested type is `image/jpeg` or `image/webp`.
1373+ * @returns {void }
1374+ * @see https://developer.mozilla.org/en-US/docs/Web/API/HTMLCanvasElement/toBlob
1375+ */
1376+ toBlob ( ...args ) {
1377+ return this . canvas . toBlob ( ...args ) ;
1378+ }
1379+
1380+ /**
1381+ * <warn>This is for web usage only, node-canvas does not support this</warn>
1382+ * Render the canvas into a Blob object representing the image contained in the canvas
1383+ * @param {string } [mimeType] A string indicating the image format. The default type is `image/png`.
1384+ * @param {number } [qualityArgument] A number between 0 and 1 indicating image quality if the requested type is `image/jpeg` or `image/webp`.
1385+ * @returns {Promise<Blob> }
1386+ */
1387+ toBlobAsync ( ...args ) {
1388+ return new Promise ( ( resolve ) => this . canvas . toBlob ( resolve , ...args ) ) ;
1389+ }
1390+
13651391 /**
13661392 * Resolves an Image or Buffer
13671393 * @param {(Image|Buffer) } imageOrBuffer An Image instance or a buffer
0 commit comments