mirror of
https://github.com/konvajs/konva.git
synced 2025-06-28 01:57:14 +08:00
Merge pull request #1675 from kawamataryo/fix-1674
Fixed toBlob to specify mineType and quality
This commit is contained in:
commit
f7c8b81dd1
@ -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);
|
||||
}
|
||||
|
@ -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();
|
||||
|
Loading…
Reference in New Issue
Block a user