Merge pull request #1675 from kawamataryo/fix-1674

Fixed toBlob to specify mineType and quality
This commit is contained in:
Anton Lavrenov 2023-11-25 10:22:24 -05:00 committed by GitHub
commit f7c8b81dd1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 21 additions and 1 deletions

View File

@ -2091,7 +2091,7 @@ export abstract class Node<Config extends NodeConfig = NodeConfig> {
this.toCanvas(config).toBlob((blob) => {
resolve(blob);
callback?.(blob);
});
}, config?.mimeType, config?.quality);
} catch (err) {
reject(err);
}

View File

@ -1368,6 +1368,26 @@ describe('Stage', function () {
}
});
it('toBlob with mimeType option using', async function () {
const stage = addStage();
const layer = new Konva.Layer();
stage.add(layer);
if (isBrowser) {
try {
const blob = await stage.toBlob({
mimeType: 'image/jpeg',
quality: 0.5,
});
assert.isTrue(blob instanceof Blob && blob.type === 'image/jpeg', "can't change type of blob");
} catch (e) {
console.error(e);
assert.fail('error creating blob');
}
}
});
it('check hit graph with stage listening property', function () {
var stage = addStage();
var layer = new Konva.Layer();